
index issue, plotting curve for engineering coursework
조회 수: 4 (최근 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!