How to make a loop through *.asc data

1 visualizzazione (ultimi 30 giorni)
Ante
Ante il 4 Lug 2023
Risposto: Aditya Singh il 5 Lug 2023
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

Risposte (1)

Aditya Singh
Aditya Singh il 5 Lug 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

Categorie

Scopri di più su Get Started with MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by