フィルターのクリア

I have a problem with plugging values into array variable

1 回表示 (過去 30 日間)
Ilay Green
Ilay Green 2023 年 7 月 29 日
コメント済み: Walter Roberson 2023 年 7 月 30 日
Hey everyone.
im trying to get values of a certain variable for 24 hours. i have latitude, longitude, height and time.
my latitude and longitude values are floats (number with decimal, e.g, 34.6796000000000,34.7128980000000,34.7462010000000,34.7794990000000
And the class of the variables that stores them (seperately, i have longitude var and latitude var) is "double"
im trying to plug these into a variable that is an array with 4 dimensions.
variable name is pm25_var(lon,lat,height,time) ("4D-single")
when im trying to plug certain coordinates like this:
firstday = pm25_var(Longitude(25),Latitude(114),1,1:24);
when 25 and 114 are the indexes of the values i want
i get this:
"Index in position 1 is invalid. Array indices must be positive integers or logical values."
how can i use the exact coordinates without rounding it into an integer?
thanks in advance

採用された回答

Stephen23
Stephen23 2023 年 7 月 29 日
firstday = pm25_var(25,114,1,1:24);
  2 件のコメント
Ilay Green
Ilay Green 2023 年 7 月 30 日
thanks! the answer I get looks like this, so i wondered if it did take the relevant coordinates:
val(:,:,1,15) =
36.6845
Thank you :)
Walter Roberson
Walter Roberson 2023 年 7 月 30 日
Remember that MATLAB only automatically collapses trailing dimensions, so when you index a variable at (scalar, scalar, scalar, vector) then the result you get out is going to be 4 dimensional with the first 3 dimensions all singular.
See also squeeze and reshape and permute

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by