1 view (last 30 days)

I have a problem with the final part of this code, I can't plot the last graphic. Thank you.

n=2000; % [rpm]

phi=0:2*pi/1000:2*pi; % [rad]

r=0.25; % [m]

l=0.57; % [m]

lam=r/l; % lambda

sb=r*(1+lam/4-cos(phi)-(lam*cos(2*phi))/4); % spostamento del pistone

syms x(ang);

x(ang)=r*(1+lam/4-cos(ang)-(lam*cos(2*ang))/4);

sb_sym=x(phi);

figure(1)

plot(phi,sb,'*',phi,sb_sym)

title('Grafico Spostamenti');

legend('spostamento [m]','spostamento:formula simbolica [m]');

grid on;

figure(2)

fplot(x,[0,2*pi])

title('Grafico Simbolico Spostamenti [m]');

syms x_dot(ang)

x_dot(ang)=diff(x(ang))

Om=n*((2*pi)/60); % omega [rad/s]

vb_sym=Om*x_dot(phi);

vb_num=Om*(diff(sb)./diff(phi));

vb=Om*r*(sin(phi)+(lam*sin(2*phi))/2);

figure(3)

plot(phi,vb,'*',phi(1:end-1),vb_num,phi,vb_sym)

title ('Grafico Velocità')

legend('velocita [m/s]','velocita:formula simbolica [m/s]');

grid on;

ab=(Om^2)*r*(cos(phi)+lam*cos(2*phi));

ab_num=(Om^2)*(diff(vb)./diff(phi));

syms vb(ang);

vb(ang)=Om*r*(sin(ang)+(lam*sin(2*ang))/2);

vb_dot(ang)=diff(vb(ang));

ab_sym=vb_dot(ang);

figure(4)

plot(phi,ab,'*',phi(1:end-1),ab(1:end-1),ab_num,phi,ab_sym) *ERROR using plot. Vectors must be same lenght

title('Grafico Accelerazione')

legend('accelerazione[m/s^2]','accelerazione:formula simbolica [m/s^2]');

grid on;

Ted Shultz
on 23 Aug 2019

you appear to have two errors on that plot line:

1) ab_sym is a symbolic expression - did you mean to exclude this?

2) what did you intend for the x axis of the ab_num plot?

You can make it clearer what you are trying to do if you change that one line to:

plot(phi,ab,'*')

hold on

plot(phi(1:end-1),ab(1:end-1))

plot(phi(1:end-1), ab_num) % assume x axis is phi(1:end-1)

% plot(phi,ab_sym) % not sure what intended

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.