Is there a function to convert column vector to matrix?
1 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
Jan
on 29 May 2021
Edited: Jan
on 29 May 2021
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 Comments
Jan
on 29 May 2021
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.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!