How to make a loop through *.asc data
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
Aditya Singh
on 5 Jul 2023
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 Comments
See Also
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!