## How can I fix the alignment

on 20 Apr 2013

### per isakson (view profile)

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]')
```

## Products

No products are associated with this question.

### per isakson (view profile)

on 20 Apr 2013
Edited by per isakson

### per isakson (view profile)

on 20 Apr 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.