Is there a function to convert column vector to matrix?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello everyone,
I am trying to create a map from below code. I have done logical indexing and therefore I have a column vector (668557x1). Kindly tell me how can I convert it to a matrix? Secondly, I am using geoshow to plot it. I just can't figure out whether problem lies in calling MOD_CER2 in geoshow or I should convert this column vector to matrix for plotting?
Any help is highly appreciated. Thank you.
MOD_CER(find(MOD_CER==-9999))=NaN;
cer = (MOD_CER).* 0.01;
index_liq = find(MOD_CP == 2);
MOD_CER2 = cer(index_liq);
댓글 수: 0
채택된 답변
Jan
2021년 5월 29일
편집: Jan
2021년 5월 29일
Hint: It is more efficient to omit the find() in:
MOD_CER(find(MOD_CER==-9999))=NaN;
% ^^^^
If you remove some arbitrary elements from a matrix, the result cannot be a matrix anymore. A matrix needs the same number of rows for each column, and columns for each row. Therefore after
index_liq = find(MOD_CP == 2);
MOD_CER2 = cer(index_liq); % 668557x1 double
it is not clear, how you want to convert it to a matrix.
Look at this small example:
x = [1, 2; 3, 4]
x(3) = [];
Now this vector x with 3 elements cannot be reshaped or whatever to be a matrix.
If you want to keep the matrix form, you need something like this:
MOD_CER2 = cer;
MOD_CER2(MOD_CP == 2) = NaN;
댓글 수: 2
Jan
2021년 5월 29일
Sorry, I do not know what "data 2 and 3" are and what the meaning of "representing liquid and ice" means. For Matlab these are all numbers. In consequence it is not clear to me, what you are asking for.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!