Effacer les filtres
Effacer les filtres

Subtracting within only 1 dimension of a multidimensional array

2 vues (au cours des 30 derniers jours)
Kate
Kate le 8 Juil 2013
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

Réponse acceptée

Matt J
Matt J le 8 Juil 2013
Modifié(e) : Matt J le 8 Juil 2013
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 commentaires
Matt J
Matt J le 8 Juil 2013
Modifié(e) : Matt J le 8 Juil 2013
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 le 9 Juil 2013
Thanks a bunch.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by