How do I convert a matrix into a single row vector?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have some consisting of natural frequencies and I'm trying to find the multiplicities (repeated) frequencies, I get my results in the form of a matrix:
naturalfreq =
1.0e+04 *
Columns 1 through 7
1.0476 1.2232 1.0476 0.2261 0.6500 0.5743 0.5743
Columns 8 through 14
0.2261 0.0603 0.1118 0.1999 0.1118 0.1724 0.1737
Columns 15 through 18
0.1724 0.0603 0.0000 0.0000
And then I recycled code I found in another question in the forum where X must be a row vector of the form X = [1 2 3 4...] or the code doesn't work, I tried a bunch of things but none worked, so I ended up building the vector manually by copying from my previous result, how can I convert it ?
X = 1.0e+04 * [ 1.0476 1.2232 1.0476 0.2261 0.6500 ...
0.5743 0.5743 0.2261 0.0603 0.1118 0.1999 ...
0.1118 0.1724 0.1737 0.1724 0.0603 1.9788e-09 ...
2.6215e-09 ];
uniqueX = unique(X);
countOfX = hist(X,uniqueX);
indexToRepeatedValue = (countOfX~=1);
freq_with_m = uniqueX(indexToRepeatedValue)
m = countOfX(indexToRepeatedValue)
total_m = numel(m)
2 Kommentare
James Tursa
am 14 Jul. 2017
I'm confused. As displayed above, the variable naturalfreq is a row vector. Why did you need to manually re-enter this data?
Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!