Subtracting within only 1 dimension of a multidimensional array

조회 수: 3 (최근 30일)
Kate
Kate 2013년 7월 8일
Question: I have a gridded array. Example:
airMetGrid <90x180x40542> single
but my air temp is in kelvin, so I need to subtract 273.15 from ONLY the 3rd dimension (and not mess up my grid). How do I do this? It seems simple but I can't wrap my brain around it today.
Thanks

채택된 답변

Matt J
Matt J 2013년 7월 8일
편집: Matt J 2013년 7월 8일
Since 273.15 is a scalar, there is no apparent difference between subtracting it from the 3rd dimension and subtracting it from the entire array.
inCelsius = airMetGrid-273.15;
  댓글 수: 2
Matt J
Matt J 2013년 7월 8일
편집: Matt J 2013년 7월 8일
Conversely, if you have a length-40542 vector, v, and want to subtract it from every airMetGrid(i,j,:), you could do
newdata=bsxfun(@minus, airMetGrid, reshape(v,1,1,[]) );
Kate
Kate 2013년 7월 9일
Thanks a bunch.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by