How to make a loop through *.asc data
1 回表示 (過去 30 日間)
古いコメントを表示
I am not so skillfull in matlab, and need your help. I found how to read data form the *.asc file, and now, based on these data I should to make loop through thair rows. How can I define that my loop goes from the first up till the late read row from the *.asc data, and how to write this expression in matlab.
You can see the problem below...
clc
clear all
close all
[filename1 pathname1]=uigetfile({'*.asc'},'file selector')
fullpathname1=strcat(pathname1,filename1)
text1=textread(fullpathname1);
%g=texread('Dfree1.txt) % this is the syntax
t=text1(:,1);
w1=text1(:,2);
w2=text1(:,3);
w3=text1(:,4);
wm=text1(:,5);
temp_out=text1(:,6);
temp_spec=text1(:,7);
DMS=text1(:,8);
s=(w2+w3)/2-w1;
for ii=1:N
dW(ii)=0.5*(text1(ii-1,8)-text1(ii,8))*(text1(ii-1,5)+text1(ii,5))
end
0 件のコメント
回答 (1 件)
Aditya Singh
2023 年 7 月 5 日
Hi Ante,
To my understanding you want to read a .asc file and iterate through the data. As the asc files contains character strings one can iterate through them and store into a cell array. In the code sample I iterate through the file one line at a time.
out = textread('test.asc','%s', 'delimiter', '\n');
C = cell2mat(out);
That just reads the whole file into a string, reading one line at a time. My test.asc was a sample asc file found Example ASC file - IBM Documentation.
For more information you can refer:
Hope it helps
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!