Read row of data from excel file and step/iterate through each row when program is looped
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Vincent Hodnett
am 6 Jan. 2020
Bearbeitet: Vincent Hodnett
am 11 Jan. 2020
Good day,
Trying to read 1 row of data each time program loops from excel file. Excel contains 2 columns of data. Each time my program loops, therefore updating values of Data1 and Data2.
Below extract of code reading imported excel file;
Disp('Currently importing from excel raw data file')
Data = xlsread('Data');%reading excel file
newData1 = Data(:,1);Reading column 1
newData2 = Data(:,2);%Reading column 2
Objective is to update equations as new data is measured, measuring using A1 and B1 1st loop, for instance.
measuring A2, B2, - 2nd iteration of programm/loop, etc....
Above is finite set of excel data, for simulation.
Thanks in advance,
kind regards Vincent
6 Kommentare
Guillaume
am 10 Jan. 2020
So, if the file is fixed why does it need to be read in a loop?
Sorry, I'm a bit confused as to what you have as input and what you want as output.
Akzeptierte Antwort
Meg Noah
am 8 Jan. 2020
Probably not the best way, but it works:
irow = 1;
Data = xlsread('fakedata.xlsx','Sheet1',['A' num2str(irow) ':B' num2str(irow)]);
while (~isempty(Data))
fprintf(1,'%f %f\n',Data(1),Data(2));
irow = irow + 1;
Data = xlsread('fakedata.xlsx','Sheet1',['A' num2str(irow) ':B' num2str(irow)]);
end
1 Kommentar
Guillaume
am 10 Jan. 2020
Hello Meg, Thanks for the advice, shall give it a go and let you know.
kind regards Vincent
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Import from MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!