Info

This question is closed. Reopen it to edit or answer.

Matrix dimensions must agree.

1 view (last 30 days)
anas nawafleh
anas nawafleh on 6 Apr 2015
Closed: MATLAB Answer Bot on 20 Aug 2021
plz help me to solve this error
Th=273+100
Tc=273+25
rp=5*10^-2
rd=10*10^-2
rcyl=12*10^-2
Ap=pi*rp^2
Ad=pi*rd^2
AH=pi*rcyl^2
AC=AH-Ap
ld=1*10^-2
lp=3*10^-2
Yo=8*10^-2
Xo=5*10^-2
LDH=0.5*10^-2
LDC=0.5*10^-2
VDH=AH*LDH
VDC=AH*LDC
VDR=pi*ld*((rcyl^2)-(rd^2))
Vd=Ad*Yo
Vp=Ap*Xo
PHI=[(0):0.001:(2*pi)]
ang=PHI*(180/pi)
X=(Xo/2)*(1+cos(PHI))
Y=(Yo/2)*(1+cos((PHI-(pi/2))))
Vh=VDH+(Y*Ad)
Vc=VDC+((Yo-Y)*Ad)+(X*Ap)
ipressure=1*10^5
R=0.287
m=((ipressure/(R*Tc))*(Vc))+((ipressure/(R*Th))*(Vh))
mo=(ipressure*Vp)/(R*Tc)
mless=m/mo
compratio=[0:0.1:100]
deadratio=VDC/Vd
tempratio=Th/Tc
A=compratio*(1+(2*deadratio))
B=compratio*((1/tempratio)-1)
z=(1+(1/A)+(B*(deadratio+1)))/(1+((1/A)+(B*compratio)))
wless=-mless*(log(z))
vt=Vh+Vc
M=3.5
p=(M*R)./((Vh/Th)+(Vc/Tc))
plot(ang,wless)
Error using /
Matrix dimensions must agree.
Error in anas (line 38)
z=(1+(1/A)+(B*(deadratio+1)))/(1+((1/A)+(B*compratio)))

Answers (1)

Image Analyst
Image Analyst on 6 Apr 2015
You need to use ./ instead of / do do an element-by-element divide:
z=(1+(1./A)+(B.*(deadratio+1)))./(1+((1./A)+(B.*compratio)))
but then you'll have a problem with the next line
wless=-mless*(log(z))
because mless is 1x6284 while z is 1x1001 elements. What is your intention there???

Community Treasure Hunt

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

Start Hunting!