how to convert the temperature from matrix 4d?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I have a matrix 4d, Size(T)=100 20 15 12, the dimensions are lat lon depth time. I need to convert the temperature Kelvin to Celsius but just in the first two dimensions. Please, how I do it? I have used "convtemp,but without success.
1 Kommentar
James Tursa
am 21 Okt. 2016
Bearbeitet: James Tursa
am 21 Okt. 2016
I don't understand what you mean by "just in the first two dimensions". You only want one plane of your array converted from Kelvin to Celsius? I.e., you deliberately want to end up with an array that has a mixture of Kelvin and Celsius temperatures in it? If the 4D array has temperatures in it, why don't you want all of it converted?
Antworten (2)
TallBrian
am 21 Okt. 2016
Hi Camila,
Your data is 4-D which means that every data point corresponds to a point in dimensions. So, when you say, I need to convert just the first two dimensions, maybe you mean I need to convert the data for all points in the first two dimensions, but only for a single value in the 3rd and 4th dimensions, which would be a plane.
In any case, you can use the following code:
kelvin2celcius = @(x) x-273.15;
data = rand(100,20,15,12);
data_new = data;
data_new(:,:,1,1) = kelvin2celcius(data_new(:,:,1,1));
example_modified = data(1,1,1,1)-data_new(1,1,1,1)
example_unmodified = data(1,1,2,1)-data_new(1,1,2,1)
Here you can see only the first index of the 3rd and 4th dimension is modified.
-Brian
0 Kommentare
Siehe auch
Kategorien
Mehr zu Statistics and Machine Learning Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!