How do I convert a matrix into a single row vector?

8 views (last 30 days)
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 Comments
James Tursa
James Tursa on 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?
quoroy
quoroy on 14 Jul 2017
you are totally right, I thought that too but I couldn't figure out why it was not giving me the right result, in this case 6 total duplicate values. I just figured out I just needed to round up the values
X = round(naturalfreq,6)
and I get the result I want.

Sign in to comment.

Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!