Problem writing data to excel.

3 views (last 30 days)
Raldi
Raldi on 4 Feb 2012
Answered: Kamohelo sekila on 20 Feb 2019
Hi everyone, i am using this code to write a 21x12 cell into excel function exportexf(dat)
namedate1=datestr(now, 1); namedate2=datestr(now, 13); namestr='data_table('; name=[namestr,namedate1,' ',namedate2,')'];
columnname = {'Algorythm', 'Starting point', 'Starting point', 'Starting point', 'Starting point', 'Starting point', 'Amplification', 'Amplification', 'Amplification', 'Amplification', 'Amplification', 'D'}; datn=[columnname;dat]; xlswrite(name, datn);
Now the code workd fine if i just copy paste it in the command line, but when i try to run the same thing from a button i created inside the data plot figure, it gives an error about Microsoft's excel and also that i should check if the folder excists, if not create it, and stuff like that. Has anyone encuntered this problem before?

Answers (2)

Image Analyst
Image Analyst on 4 Feb 2012
You should learn how to use the debugger to examine variables. If you had, you would have seen that name = 'data_table(04-Feb-2012 15:40:03)' or similar. Of course you know that the first argument to xlswrite is a filename and filenames cannot have colons in them, unless it's right after a drive letter, which yours is NOT. Also, "dat" was never defined. Keep working on it!
  2 Comments
Image Analyst
Image Analyst on 4 Feb 2012
Set a breakpoint on the xlswrite() line. Then, when it stops there, type this on the command line:
name
then come back and tell me what it says. Copy and paste - don't paraphrase. Then hit F10 to execute the xlswrite() line. Again, copy and paste ALL of the red text from the command window back here.

Sign in to comment.


Kamohelo sekila
Kamohelo sekila on 20 Feb 2019
Hi everyone,
I need to simulate a Continuous stirred-tank reactor model (CSTR) and extract data from that simulation. Basically, the CSTR is a common model for a chemical reactor in chemical engineering. This model is used to estimate the key unit operation variables when using a continuous agitated-tank reactor to reach a specified output (from wikepedia)
The CSTR is normally two first order differential equations which represents both material balance and energy balance in the reactor. One equation is for reactor temperature (T) and the other is for reactor concentration (T). There are also several measurements that can be made from the process. e.g. Temperature of the process, temperature of the reactant in the inlet pipe on the reator, volume or level of the material in the reactor, concentraction of the output product e.t.c.
The model (Differential equations) can be solved by Matlb ODE45 solver, for example to get T and C over time. I have done this. However, this is not what I want to do. I want to get data from measurements on the model. I want to get temperature of the reactant, temperature of the product, volume or level of the material in the reactor. I don't know how I am going to do this.
I tried exploring Simulink to built the model, thinking that I may be able to put 'sensors' within Simulink which will then give me what I want. I can not seem to achieve anything with this thinking as I don't know how to model the sensors. How can I achieve this in Matlab?
Lastly, I want to export the data that I get from Matlab to Microsoft excel. That is, data from all the measurements of different temperatures that I mentioned, the volume and all the concentrations values over time. How can I achieve this?

Community Treasure Hunt

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

Start Hunting!