Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Actually I am reading two different files in a for loop and I am able to read these files name separately by using for loop but I have to save Z variable values each time of each file separately. Need help in this. Thanks in advance.

2 ビュー (過去 30 日間)
ibadullah safdar
ibadullah safdar 2016 年 11 月 27 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
clc clear all
fls = dir( 'delta_his_pre_Pakistan_*.ASC' );
for i=1:2
a(i,1)=fls(i,1)
fn=a(i,1).name
[Z,R]=arcgridread(fn);
end

回答 (1 件)

KSSV
KSSV 2016 年 11 月 28 日
fls = dir( 'delta_his_pre_Pakistan_*.ASC' );
for i=1:2
[pathstr,name,ext] = fileparts(filename) ;
a(i,1)=fls(i,1)
fn=a(i,1).name
[Z,R]=arcgridread(fn);
%%save to text file
fname = strcat(name,'.txt') ;
save(fname,'Z','-ascii') ; % save to text file
%%save to mat file
fname = strcat(name,'.mat') ;
save(fname,'Z') ;
end

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by