Inserting another column into an existing table

I am having trouble getting all of my data into one table. So far, I have this code:
TF=(40:-10:-40)';
Vmph=10:10:60;
Twc=round(35.74+0.6215*TF-35.75*Vmph.^0.16+.4275*TF.*Vmph.^0.16);
TBL1=[TF,Twc];
fid1=fopen('WindChillTemperature.txt','wt');
fprintf(fid1,'Wind Chill Table\n \n');
fprintf(fid1,' Temperature(F) \n');
fprintf(fid1,' %10.0f %10.0f %10.0f %10.0f %10.0f %10.0f %10.0f %10.0f %10.0f\n',TBL1);
fclose(fid1);
I now need to get the Vmph data in front of the first column that comes up. Anyone have any ideas?

Respuestas (1)

Stephen23
Stephen23 el 28 de Sept. de 2018
Editada: Stephen23 el 28 de Sept. de 2018
I am guessing that you want that data in columns, something like this:
TF = 40:-10:-40;
Vmph = 10:10:60;
Twc = round(35.74+0.6215*TF-35.75*Vmph.^0.16+.4275*TF.*Vmph.^0.16);
mat = [TF(:),Vmph(:),Twc(:)];
[fid,msg] = fopen('WindChillTemperature.txt','wt');
assert(fid>=3,msg)
fprintf(fid,'Wind Chill Table\n \n');
fprintf(fid,'Temperature(F)\tVelocity(MPH)\tTwc\n');
fprintf(fid,'%10.0f\t%10.0f\t%10.0f\n',mat.'); % note the transpose!
fclose(fid);

Categorías

Más información sobre Reporting and Database Access en Centro de ayuda y File Exchange.

Preguntada:

el 27 de Sept. de 2018

Editada:

el 28 de Sept. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by