index issue, plotting curve for engineering coursework

조회 수: 4 (최근 30일)
Richard Gray
Richard Gray 2019년 3월 26일
댓글: Richard Gray 2019년 3월 26일
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

채택된 답변

Stephan
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
  댓글 수: 1
Richard Gray
Richard Gray 2019년 3월 26일
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?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by