Info

此问题已关闭。 请重新打开它进行编辑或回答。

Keep getting "Unable to perform assignment because the indices on the left side are not compatible with the size of the right side."

1 次查看(过去 30 天)
clear all;
close all;
clc;
global t Ts Tm T Qmax CVS CVD tauD tauS
% Initial Conditions
Rs = 17.5; % mmHg/(liter/min)
Rp = 1.79;
Csa = 0.01;% liters/mmHg
Csv = 1.75;
Cpa = 0.00667;
Cpv = 0.08;
Kr = 2.8; % (liters/min)/mmHg
Kl = 1.12;
V0 = 5.0; % Liters
%Time Span
Ts=0.0050; % (minutes) length of systolic phase
Tm=0.0020; % (minutes) length of diastolic phase
Qmax=28; % (liters/minute) maximum flow
T=0.0125; % (minutes) How many minutes it takes for a single heartbeat
t=linspace(0,T,1000);
%Compliance Variables
CVD = 0.0146; %Liters/mmHg Starting Clvd value
CVS = 0.00003; %Liters/mmHg Starting Clvs value
tauS = 0.0025; %Minutes
tauD = 0.0075; %Minutes
% Flow
for i=1:length(t)
if 0<=t(i) && t(i)<=Tm
Q(i)=Qmax*t(i)/Tm;
elseif Tm<=t(i) && t(i)<=Ts
Q(i)=Qmax*(Ts-t(i))/(Ts-Tm);
else
Q(i)=0;
end
end
plot(t,Q);
hold on
%Q For Sytemic Arteries
for i = 1:length(t)
if 0<=t(i) && t(i)<=Tm
Qsa(i) = (Qmax.*t)/Tm; %%Error appears here
elseif Tm<=t(i) && t(i)<=Ts
Qsa(i) = (Qmax.*(Ts-t))/(Ts-Tm);
elseif Ts<=t(i) && t(i)<= T
Qsa(i) = 0;
end
end
plot(t,Qsa)

回答(1 个)

Dhanashree Mohite
As per my understanding Line no. 41 and 43 should contain t(i) instead of t.
Line no. 43 should be
Qsa(i) = (Qmax.*(Ts-t(i)))/(Ts-Tm);
Line no. 41 should be
Qsa(i) = (Qmax.*t(i))/Tm; %%Error appears here

此问题已关闭。

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by