New Reply

Simple MATLAB to Excel Question

 
Share Thread Thread Tools
Jun19-12, 11:49 AM   #1
 

Simple MATLAB to Excel Question


I've discovered that MATLAB is not my forte. I have a 51x3 matrix that I want to print to an Excel sheet, but with column headers. I can get the matrix into an Excel file and I can get the headers into an Excel file, but I cannot figure out how to get the two together. I've looked up how to do this and it is not working for me.

What I have is

Code:
sunAngleMtx(:,1) = results.Timestamp;
sunAngleMtx(:,2) = results.SubTargetID;
sunAngleMtx(:,3) = results.SunAngle;

data = {'Timestamp','SubTargetID','SunAngle'; sunAngleMtx};
xlswrite('sunAngleData.xls', data);
and I'm getting the error
Error using vertcat
CAT arguments dimensions are not consistent.

Error in sunAngleCheck (line 12)
data = {'Timestamp','SubTargetID','SunAngle'; sunAngleMtx};
Any idea what I'm doing wrong. I imagine this is just me being a MATLAB noob.

Thanks in advance.
 
PhysOrg.com
PhysOrg
science news on PhysOrg.com

>> Front-row seats to climate change
>> Attacking MRSA with metals from antibacterial clays
>> New formula invented for microscope viewing, substitutes for federally controlled drug
Jul26-12, 08:00 AM   #2
 
Solved.
 
Jul26-12, 08:24 AM   #3
 
Mentor
How? Other people might find it useful.
 
Jul26-12, 08:50 AM   #4
 

Simple MATLAB to Excel Question


Code:
data = 'Timestamp,SubTargetID,SunAngle\n';
fout = fopen('sunAngleData.csv','wt');
fprintf(fout,data);
fprintf(fout,'%d,%f,%f,%f,%f,%f\n',sunAngleMtx');
fclose(fout);
 
New Reply
Thread Tools


Similar Threads for: Simple MATLAB to Excel Question
Thread Forum Replies
2-D temperature Distribution - Matlab or Excel Engineering, Comp Sci, & Technology Homework 0
How to export Matlab curve-fitted data to excel? Math & Science Software 2
Exporting data from matlab to excel Math & Science Software 3
VBA Excel UserForm :: Simple Question Programming & Comp Sci 8
Matlab - importing data from excel & interpolating Programming & Comp Sci 1