
index issue, plotting curve for engineering coursework
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Stephan
2019-3-26
编辑:Stephan
2019-3-26
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
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!