5 views (last 30 days)

I wanted to know how to plot my a graph for my function. The x-axis needs to be values of 'v' from from 1-10. The y-axis is the values of the function y(v). I want to label the x-axis: v [mol/m^3] and y-axis y(v). How would I write the code for this? Below is the some of the code I have written.

P=2020000;%P,R,a,b are all constants

R=8.314;

a=0.16330;

b=0.00002401;

v=[0:1:10];%range of v values for the x-axis

y=((R*T)/(v-b))+((a)/((v^2+(2*b*v)-b^2)))+P

plot(v,y)

Sivakumar Selvam
on 4 Feb 2020

P=2020000;%P,R,a,b are all constants

R=8.314;

a=0.16330;

b=0.00002401;

v=[0:1:10];%range of v values for the x-axis

y=((R*T)/(v-b))+((a)/((v^2+(2*b*v)-b^2)))+P

plot(v,y);

xlabel('v [mol/m^3]')

ylabel('y(v)')

Prashanth Darla
on 4 Feb 2020

Edited: Prashanth Darla
on 4 Feb 2020

Hey,you're all good if you declare T and elemenmtwise operatorfor division and power (Here I used T as 1)

Here's the code I suggest for you

P=2020000;%P,R,a,b are all constants

R=8.314;

a=0.16330;

b=0.00002401;

T=1;

v=(1:1:10);

disp(v);

for i =v

%range of v values for the x-axis

y=(((R*T)./(i-b))+((a)./((i.^2+(2*b*i)-b.^2)))+P);

disp(y);

end

plot(v,y);

xlabel('v [mol/m^3]')

ylabel('y(v)')

Hope this solves the issue.

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.