From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

matlab to labview

data=load('D:\d.txt');

 

for n=1:240;

    t=1024*n; i=t-1024+1;

    a=data(i:t,1);

    elev=-data(i:t,2);

    p=data(i:t,3);

    r=-data(i:t,4);

 

 

please ane one help how to code in labview for above matlab procedue.. urgent please 

 

 

thanks & regards

srinath 

0 Kudos
Message 1 of 8
(3,437 Views)

Hi adapa,

can you explain a bit? What is it doing?

Is it a loop over the following lines?

 

You can load it like shown in the attached picture.

 

Mike

Message 2 of 8
(3,430 Views)

Use array index to get the vectors a, elev, p, and r.

 

Lynn 

Message 3 of 8
(3,389 Views)

ya after that loop will be over 

the meaning of the above matlab coding is 

here i am sending text file also.. here the first column shows the data of the ''a''

                                                the second  column shows the data of the ''elev''

                                                the thied column shows the data of the ''p'' 

                                                 the first column shows the data of the ''r'' 

for n =1:240; shows that loop count is 1 to 240

                                                                

                                                              t=1024*n; i=t-1024+1; shows the conditions 

                                                                a=data(i:t,1); shows during hte first loop it has to read first column 1024 values and during the 2nd loop count t has to read first column 1025 to next 2048 values and cont.. up to 140 times

                                                                elev=-data(i:t,2); shows during first  loop it has to read 2nd column 1024 values and during the 2nd loop count 2ndhas to read 2nd column 1025 to next 2048 values and cont.. up to 140 times

                                                                 p=data(i:t,3); shows during first  loop it has to read 3rd column 1024 values and during the 2nd loop count 2ndhas to read 3rd column 1025 to next 2048 values and cont.. up to 140 times

                                                                  r=-data(i:t,4);shows during first  loop it has to read4th column 1024 values and during the 2nd loop count 2ndhas to read 4th column 1025 to next 2048 values and cont.. up to 140 times 

 

                                                                      end

 

 i think ex:

 

 

 

thanks and regards

 srinath 

  

 

0 Kudos
Message 4 of 8
(3,363 Views)

working priciple example of of a=data(i:t,1);

 

Syntax

silhouette(X,clust)
s = silhouette(X,clust)
[s,h] = silhouette(X,clust) 
[...] = silhouette(X,clust,metric)
[...] = silhouette(X,clust,distfun,p1,p2,...)

Description

silhouette(X,clust) plots cluster silhouettes for the n-by-p data matrix X, with clusters defined by clust. Rows of X correspond to points, columns correspond to coordinates. clust can be a categorical variable, numeric vector, character matrix, or cell array of strings containing a cluster name for each point. (See Grouped Data.) silhouette treats NaNs or empty strings in clust as missing values, and ignores the corresponding rows of X. By default, silhouette uses the squared Euclidean distance between points in X.

s = silhouette(X,clust) returns the silhouette values in the n-by-1 vector s, but does not plot the cluster silhouettes.

[s,h] = silhouette(X,clust) plots the silhouettes, and returns the silhouette values in the n-by-1 vector s, and the figure handle in h.

[...] = silhouette(X,clust,metric) plots the silhouettes using the inter-point distance function specified in metric. Choices for metric are given in the following table.

MetricDescription
'Euclidean'

Euclidean distance

'sqEuclidean'

Squared Euclidean distance (default)

'cityblock'

Sum of absolute differences

'cosine'

One minus the cosine of the included angle between points (treated as vectors)

'correlation'

One minus the sample correlation between points (treated as sequences of values)

'Hamming'

Percentage of coordinates that differ

'Jaccard'

Percentage of nonzero coordinates that differ

Vector

A numeric distance matrix in upper triangular vector form, such as is created by pdist. X is not used in this case, and can safely be set to[].

 

[...] = silhouette(X,clust,distfun,p1,p2,...) accepts a function handle distfun to a metric of the form

d = distfun(X0,X,p1,p2,...)

where X0 is a 1-by-p point, X is an n-by-p matrix of points, and p1,p2,... are optional additional arguments. The function distfun returns an n-by-1 vector d of distances between X0 and each point (row) in X. The arguments p1, p2,... are passed directly to the function distfun.

Remarks

The silhouette value for each point is a measure of how similar that point is to points in its own cluster compared to points in other clusters, and ranges from -1 to +1. It is defined as

S(i) = (min(b(i,:),2) - a(i)) ./ max(a(i),min(b(i,:)))

where a(i) is the average distance from the ith point to the other points in its cluster, and b(i,k) is the average distance from the ith point to points in another cluster k.

Examples

X = [randn(10,2)+ones(10,2);randn(10,2)-ones(10,2)];cidx = kmeans(X,2,'distance','sqeuclid');s = silhouette(X,cidx,'sqeuclid');

 

0 Kudos
Message 5 of 8
(3,360 Views)

hai 

i used it . but i didnt get as per my requirement.

 i attached my text file also ...

and working principle also i given in above posts .

 

can u try based on that .....

 

 

 

thanks & regards

srinath 

0 Kudos
Message 6 of 8
(3,359 Views)
hai up to 240 times it has to count .. not 140 .. i did a mistake in above post sorry...
0 Kudos
Message 7 of 8
(3,356 Views)
This post has been apparently closed, as it has been solved.
0 Kudos
Message 8 of 8
(3,330 Views)