save data all of in loop

2 ビュー (過去 30 日間)
il147
il147 2021 年 10 月 9 日
コメント済み: il147 2021 年 10 月 9 日
I have problem with saving data in loop
I'd like to seperate lon and lat which are saved in num
lon is saved num(1), num(3),num(5)......, and lat is num(2),num(4),num(6)......
That is my code and num
num=xlsread('ENVISAT.ex.xlsx');
num=num(~isnan(num));
num=nonzeros(num)
i=0
lon=[];
lat=[];
for i=1:30
i=i+um
lon=num(i+1)
lat=num(2*i+1)
end

採用された回答

Rik
Rik 2021 年 10 月 9 日
No loop required:
num=xlsread('ENVISAT.ex.xlsx');
num=num(~isnan(num));
num=nonzeros(num);
lon=num(1:2:end);
lat=num(2:2:end);
In your code it was overwriting the variable every iteration, instead of indexing.
  1 件のコメント
il147
il147 2021 年 10 月 9 日
It works!!!!!!!!
You are the best :) Thanks!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by