Format printing problem with doubles printing in rows when I am looking for columns.
Mostra commenti meno recenti
prompt = {'Theta 1', 'Theta 2', 'Theta 3', 'Theta 4', 'Theta 5'};
prompt2 = {'Radius 1', 'Radius 2', 'Radius 3', 'Radius 4', 'Radius 5'};
dlgtitle = '\Theta values 0 -> 260';
dlgtitle2 = 'Radius values 2-20';
t = inputdlg(prompt, dlgtitle);
r = inputdlg(prompt2, dlgtitle2);
radius = cellfun(@str2num, r);
theta = cellfun(@str2num, t);
[x,y] = Pol2Rect(radius, theta);
fileName = 'prog9_OUTPUT_JMG.txt';
fileID = fopen(fileName, 'w');
header1 = 'Polar Coordinates';
header2 = 'Rectangular Coordinates';
header3 = 'Table 1 Polar Coordinates Converted to Rectangular Coordinates';
%prints out the formatted table
fprintf(fileID, '\t%s\n\n', header3);
fprintf(fileID,'%s\t\t\t\t%s\n\n',header1, header2);
fprintf(fileID,'R(meters) Theta(degrees) x(meters) y(meters)\n');
fprintf(fileID,'%5.1f\t%5.1f\t\t\t\t%5.1f\t%5.1f \n', radius, theta, x, y);
fclose(fileID);

1 Commento
Jacob
il 4 Nov 2024
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Startup and Shutdown in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!