how to convert the temperature from matrix 4d?

조회 수: 1 (최근 30일)
Camila Hashimoto
Camila Hashimoto 2016년 10월 21일
답변: Camila Hashimoto 2016년 10월 21일
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
James Tursa
James Tursa 2016년 10월 21일
편집: James Tursa 2016년 10월 21일
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?

댓글을 달려면 로그인하십시오.

답변 (2개)

TallBrian
TallBrian 2016년 10월 21일
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

Camila Hashimoto
Camila Hashimoto 2016년 10월 21일
Hi Brian, thanks a lot!

카테고리

Help CenterFile Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by