index issue, plotting curve for engineering coursework

4 views (last 30 days)
Hello everyone,
I'm attempting to plot a function for an engineering report on balloon inflation. Im attempting to plot stretch vs pressure, but MATLAB suggests that my "index exceeds array bounds" - im not sure why, i'm just after an output value for Y across a range of input values for P. my code as below;
clear
clc
%initial parameters
%axial case
pi = 3.14153;
re = 1e-3;
rif = 0.25e-3;
l = 2e-3;
mu = 0.4;
rhoc = 2700000*re/2*(re-rif);
rhot = rhoc/2;
%equations
P = 200000:100000:2700000;
Y = (pi*rhot*(re^2-rif^2)) / (l*(pi(P)*rif-2*mu*(pi*(P)*rif+rhoc*re+rhoc*rif)));
equation is rearranged to make Y the subject, as i don't know it but have a known range of P values to use.
plot(P,Y)
Thanks
Rich

Accepted Answer

Stephan
Stephan on 26 Mar 2019
Edited: Stephan on 26 Mar 2019
Hi,
no need to define pi - it is a constant in Matlab already. Your issue is:
pi(P)
which is interpreted as the P'th value of pi. I used:
pi.*P
which i guessed to be meant. This gives:
%initial parameters
%axial case
re = 1e-3;
rif = 0.25e-3;
l = 2e-3;
mu = 0.4;
rhoc = 2700000*re/2*(re-rif);
rhot = rhoc/2;
%equations
P = 200000:100000:2700000;
Y = (pi*rhot*(re^2-rif^2))./(l*(pi.*P*rif-2*mu*(pi.*P*rif+rhoc*re+rhoc*rif)));
plot(P,Y)
with result:
Best regards
Stephan
  1 Comment
Richard Gray
Richard Gray on 26 Mar 2019
thank you very much, it works for me!
just as an aside; if i rearranged this so P was on the LHS (the original form i had this equation in), would i still be able to plot P against Y even though Y is unknown?

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!