Is there a function to convert column vector to matrix?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Jan
am 29 Mai 2021
Bearbeitet: Jan
am 29 Mai 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 Kommentare
Jan
am 29 Mai 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.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!