how to store data result to excel from an equation in matlab for a simulation

2 views (last 30 days)
Hi All,
I want to know how can we write multiple data strings in the same excel sheet for a design simulation. As We know that whenever we specify xlswrite command it starts writing from cell A1 of the excel sheet.
Now, my problem is I am carrying out a design calculation for a treatment works. At the end of the design calculation I am storing the variables in the excelsheet using xlswrite command. Now for a set of values of particular variable A , I want to do all the design calculations and then store them consecutively one calculation after the other in excel sheet in different rows. How can we do it. I tried to run for loop but it always stores the data in the first row of the excelsheet so only the last set of data is available through xlswrite statement.
Program is a gui,the user will be prompted to enter values which will be calculated using different values of a and b and upon calculation the user will click a button to create an excel file and save the values for about 24 sessions
a= handles.edit1;
b= handles.edit 2;
y = a^2 + b;
then finally I use xls write to write all these variables in an excelsheet.
Now for a range of values for variables and b I want y to be calculated 24 times and store them in the same excel sheet row wise. How can one do it . I would appreciate if someone comes up with a solution.
Regards

Answers (1)

dpb
dpb on 14 Oct 2017
"As We know that whenever we specify xlswrite command it starts writing from cell A1 of the excel sheet."
Au contraire, "we" don't know that...
>> help xlswrite
xlswrite Write to Microsoft Excel spreadsheet file.
...
xlswrite(FILE,ARRAY,RANGE) writes to the rectangular region
specified by RANGE in the first worksheet of the file. Specify RANGE
using the syntax 'C1:C2', where C1 and C2 are opposing corners of the
...
You can write wherever you wish.
Just compute y for the x vector (ensure it's a row, not column if that's the orientation you want) and then call xlswrite with that array.

Community Treasure Hunt

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

Start Hunting!