How can I fix the alignment
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
The first 10 answers are vertically aligned in a way and the remaining values in another way. How can i fix that?
Here is the program:
nn=length(0:10:720);
P=zeros(nn,1);
V=zeros(nn,1);
x=zeros(nn,1);
alfa_cont=zeros(nn,1);
for alfa=0:10:720
cont=alfa/10+1;
cos_alfa=cosd(alfa);
alfa_cont(cont)=alfa;
x(cont)=76.8*((1-cos_alfa)/2+0.28/4-(0.28/4)*cos_alfa^2);
if (alfa<=180)
P(cont)=0.9;
elseif (alfa<=360)
P(cont)=320.612/((x(cont)+8.93023)^1.32);
elseif (alfa<=540)
P(cont)=1119.9/((x(cont)+8.93023)^1.24);
else
P(cont)=1.1;
end
V(cont)= 0.0448882+x(cont)*pi*(80^2)/4*(10^(-6));
end
figure(1)
plot(V,P,'-r'),title('Diagram P-V'),xlabel('Volume [l]'),ylabel('Pressure [bar]'),grid;
fprintf('\n')
fprintf('alfa\t\tx[mm]\t\tP[bar]\t\tV[l]\n')
fprintf('%-6.4f\t\t%-6.4f\t\t%-6.4f\t\t%-6.4f\n',[alfa_cont x P V]')
0 commentaires
Réponse acceptée
per isakson
le 20 Avr 2013
Modifié(e) : per isakson
le 20 Avr 2013
This does it
fprintf('%8s\t\t%8s\t\t%8s\t\t%8s\n', 'alfa', 'x[mm]', 'P[bar]', 'V[l]' )
fprintf('%8.4f\t\t%8.4f\t\t%8.4f\t\t%8.4f\n',[alfa_cont, x, P, V]')
alfa x[mm] P[bar] V[l]
0.0000 0.0000 0.9000 0.0449
10.0000 0.7455 0.9000 0.0486
20.0000 2.9447 0.9000 0.0597
....
100.0000 50.2820 0.9000 0.2976
110.0000 56.2807 0.9000 0.3278
120.0000 61.6320 0.9000 0.3547
Mixing tabs a spaces is not robust. Depends on the settings of the tabs-positions.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Genetic Algorithm dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!