I´m trying to plot this function, which is an analytical solution of a partial equation, the equiation is below. This is my scipt. I don´t why that error is still apearing.
%Data
L=1; %m
p=1; %kg/m^3
G=0.1; %kg/ms
u=0.1; %m/s
%Boundary Conditions
po=1;
pL=0;
x=0:0.1:L;
p_a=((exp.((p*u)/G.*x)-1)./(exp(p*u*L/G)-1).*(pL-po))+po;
plot(x,p_a)
I get this error:
>> p_a=((exp.((p*u)/G.*x)-1)./(exp(p*u*L/G)-1).*(pB-pA))+pA;
Matrix dimensions must agree.

 채택된 답변

KSSV
KSSV 2020년 12월 15일

2 개 추천

It should be exp() not exp.()..there is a typo error.
%Data
L=1; %m
p=1; %kg/m^3
G=0.1; %kg/ms
u=0.1; %m/s
%Boundary Conditions
po=1;
pL=0;
x=0:0.1:L;
p_a=((exp((p*u)/G.*x)-1)./(exp(p*u*L/G)-1).*(pL-po))+po; % <---- changed here in first exp
plot(x,p_a)

댓글 수: 3

Guillermo Nuñez
Guillermo Nuñez 2020년 12월 15일
Hi! Thanks for your answer, there´s still the same error. Any other idea?
KSSV
KSSV 2020년 12월 16일
There is no error......see the attched plot. Showus the code which you tried which lead to error.
Guillermo Nuñez
Guillermo Nuñez 2020년 12월 16일
You´re right man! I was solving in the same code the equation by a numerical way and declared the numerical vector solution as "p", same variable name as the density. Sorry I didn´t checked it before. Thank you so much bro.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품

릴리스

R2020b

질문:

2020년 12월 15일

댓글:

2020년 12월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by