MATLAB Answers

Data must be numeric, datetime, duration or an array convertible to double.

12 views (last 30 days)
Anyone can help me ?
How can i fix this?There is error in line 23
% this program computes and plots the exact cylinder volume
clear();
r = 8; % compression ratio
s = 100; % stroke (mm)
b=s; %bore=stoke
len= 150; %connecting rod length (mm)
Vd= b^2*s*pi/4; %displacement volume
Vc=Vd/(r-1) %clearence volume
a=s/2; % radius of crank shaft
theta=-180:1:180; %crankangle theta vector
y =len+a-((len^2-a^2*sind(theta).^2).^(1/2) +a*cosd(theta)); % .^2).^ nokta istiyor exact
vol= Vc+y*b^2*pi/4; % exact volume
syms theta
dvdtheta=vol
diff(dvdtheta) %dv /dtheta
%plot results
figure;
plot(theta,diff(dvdtheta),'--','linewidth',2);
xlabel('Crank Angle (deg)','fontsize', 18);
ylabel('dv/dtheta mm3','fontsize', 18);
axis ([-200 200 -1000000 1000000])
legend( 'dv/dtheta','Location', 'North');

  0 Comments

Sign in to comment.

Accepted Answer

Ameer Hamza
Ameer Hamza on 9 Apr 2020
See the difference between following code and your code
% this program computes and plots the exact cylinder volume
clear();
r = 8; % compression ratio
s = 100; % stroke (mm)
b=s; %bore=stoke
len= 150; %connecting rod length (mm)
Vd= b^2*s*pi/4; %displacement volume
Vc=Vd/(r-1); %clearence volume
a=s/2; % radius of crank shaft
theta=-180:1:180; %crankangle theta vector
y =len+a-((len^2-a^2*sind(theta).^2).^(1/2) +a*cosd(theta)); % .^2).^ nokta istiyor exact
vol= Vc+y*b^2*pi/4; % exact volume
% syms theta % no need for symbolic variable
dvdtheta=vol;
diff(dvdtheta) %dv /dtheta
%plot results
figure;
plot(theta,gradient(dvdtheta),'--','linewidth',2); % use gradient function
xlabel('Crank Angle (deg)','fontsize', 18);
ylabel('dv/dtheta mm3','fontsize', 18);
% axis ([-200 200 -1000000 1000000])
legend( 'dv/dtheta','Location', 'North');

  0 Comments

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!