How do I convert a matrix into a single row vector?
조회 수: 8 (최근 30일)
이전 댓글 표시
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
James Tursa
2017년 7월 14일
I'm confused. As displayed above, the variable naturalfreq is a row vector. Why did you need to manually re-enter this data?
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!