Why don't these matrix dimensions agree?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
sophie webster
am 29 Mär. 2015
Beantwortet: Star Strider
am 29 Mär. 2015
Nlayers=20; %number of layers in the lung
z=(1:Nlayers);
TLC=7; %total lung capacity
Htot=0.16; %total lung height, metres
plung=300; %lung density kg/m3
Vad=0.15; %Volume of the anatomical dead space
g=9.81; %Gravitational acceleration
Fs=64;
dt=1/Fs;
StopTime=8;
t=(0:dt:StopTime-dt);
Nalvtot=300;
Nalvz=Nalvtot/Nlayers; %Number of alveoli in a layer
r=(0.00009)*sin(1.57*t)+(0.00013); %alveolar radius
Valvz=(4/3)*pi*r.^3; %volume of the alveolus
Vtotal=Vad+Nalvz*Valvz*20;
Pcw=0.71-((0.95*TLC)/((Vtotal/TLC)-(0.22*TLC))-1)*0.58; %Pressure component of the chest wall
When i run this it says
"Error using /
Matrix dimensions must agree.
Error in Pcw_stripped (line 21)
Pcw=0.71-((0.95*TLC)/((Vtotal/TLC)-(0.22*TLC))-1)*0.58; %Pressure component of the chest wall
Error in run (line 63)
evalin('caller', [script ';']);"
But I'm sure why? Help!
0 Kommentare
Akzeptierte Antwort
Star Strider
am 29 Mär. 2015
You need to vectorise that line, doing element-wise operations. In this instance, that means replacing (/) with (./).
See if this improves your code:
Pcw=0.71-((0.95*TLC)./((Vtotal./TLC)-(0.22*TLC))-1)*0.58; %Pressure component of the chest wall
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Particle & Nuclear Physics finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!