for loop and xlswrite

3 Ansichten (letzte 30 Tage)
Muhammad Usman
Muhammad Usman am 1 Jul. 2014
Kommentiert: Muhammad Usman am 1 Jul. 2014
Hi,i want to use xlswrite to write my data using for loop but the issue I am facing that if i have for loop with decimal interval then how can i write it to excel (discrete cells),e.g
for k=1:0.5:5
x=rand;
my_cell = sprintf( 'A%s',num2str(k) );
xlswrite('my_xls.xls',x,1,my_cell);
end
by using this i got error,please help me in writing such stuff. Thanks* |

Akzeptierte Antwort

Sara
Sara am 1 Jul. 2014
K is not an integer so you can't use it to select the excel cell. Do this:
j = 0;
for k=1:0.5:5
j = j + 1;
x=rand;
my_cell = sprintf( 'A%s',num2str(j) );
xlswrite('my_xls.xls',x,1,my_cell);
end

Weitere Antworten (0)

Kategorien

Mehr zu Data Export to 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!

Translated by