
index issue, plotting curve for engineering coursework
4 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
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
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!