How to write a continuosly extending matrix ( sample1=[3 2 3 4 1 2;sample] ) to an excel sheet cell by cell?

1 view (last 30 days)
The incoming data from serial connection writes the values in the sample matrix (sample values) changing each second, as:
semval = []
semval = [semval; sample1, sample2, sample3, sample4, sample5, sample6, sample7, sample8];
i want to export this data continuously to an excel sheet with each matrix element in different cells in the excel, i tried dlmwrite and csvwrite commands, but they output all line in just one cell. Outputing cell by cell is possible?

Answers (4)

kaan yilmaz
kaan yilmaz on 11 Feb 2012
Isn't there anyone here who knows the answer?

Image Analyst
Image Analyst on 11 Feb 2012
Your first line initializing semval to null is unnecessary. This code works fine.
sample1 = 100;
sample2 = 200;
sample3 = 300;
sample4 = 400;
sample5 = 500;
sample6 = 600;
sample7 = 700;
sample8 = 800;
semval = [sample1, sample2, sample3, sample4, sample5, sample6, sample7, sample8]
csvwrite('test.csv', semval);
Each number is in one cell of Excel. I'm not sure what you did to mess it up. Alternatively, did you try xlswrite()?
If you want to write one cell at a time, like in a for loop, then you'll have to use ActiveX, because csvwrite, dlmwrite, and xlswrite all just write out the entire set of data in one batch operation, not cell by cell. See my posts here in Answers where I gave ActiveX demo code.

kaan yilmaz
kaan yilmaz on 11 Feb 2012
now i am trying it, the time is rising second by second at a variable "timex" , here for an example i assigned a value to "timex".
col_header={'TIME','Thermocouple1','Thermocouple2','Thermocouple3','Thermocouple4','Thermocouple5','Thermocouple6','Distance','Pressure'};
timex=50;
abc=1:timex;
row_header(abc,1)={'string'};
xlswrite('Result.xls',semval,'Sheet1','B2');
xlswrite('Result.xls',col_header,'Sheet1','A1');
xlswrite('Result.xls',row_header,'Sheet1','A2');
here the problem is, i want to update the first row headers as changing variable of "timex" by passing time, how can i do? maybe something like
row_header(abc,1)={'string',timex};
but this gives error

kaan yilmaz
kaan yilmaz on 11 Feb 2012
Anyone help please, how can i make matlab write the row_header(abc,1) value changing in every row from up to down?

Community Treasure Hunt

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

Start Hunting!