How could i run the loop?

2 次查看(过去 30 天)
M.Rameswari Sudha
I want to get the value for q,v and TC. I couldnt solve this problem using this code. Can anyone help me?
clc
close all
k=50;
c=20;
h=2;
H=2;
w0=20;
w1=0.1;
s=40;
del=0.05;
alpha0=0.08;
k0=50;
c0=1;
lambdai = [220 250 280 310 500];
lambda=1250;
the2=0.5;
mu=[500 500 500 500 500];
b=[50 70 100 120 130];
M = zeros(length(lambdai), length(b), length(mu));
for i = 1:length(lambdai)
C(i) = lambdai(i);
rho(i)= (1-(lambdai(i)./mu(i)));
B1(i)=((b(i).*lambdai(i))./lambda);
q(i)=sqrt(((H+c0.*w1.*the2+b(i)).*w0.*the2)./(s.*alpha0.*del.*(1-rho(i)).*rho(i)+(H+c0.*w1.*the2).*rho(i).*{2}).*(H+c0.*w1.*the2+b(i)));
v(i)=-((H+c0.*w1.*the2).*rho(i).*q(i))./((H+c0.*w1.*the2+b(i)))
mu1(i)=mu(i);
TC(i)=c.*lambda(i)+y.*(a.*log(k0./k)+b(i).*log(beta0./beta))+(q(i)./2.*rho(i)).*((s.*alpha0.*del.*(1-rho(i)).*rho(i))+(H+c0.*w1.*the2).*rho(i).^{2}.*b(i).^{2}+((b(i).*((H+c0.*w1.*the2).*rho(i)).^{2})./(H+c0.*w1.*the2+b(i))).^{2})+(c0.*w0.*the2./q(i))
i=1+1
end
TCC=TC(i)
  3 个评论
M.Rameswari Sudha
while I was running the program we get,
??? Undefined function or method 'times' for input arguments of type
'cell'.
Error in ==> Imperfect at 24
q(i)=sqrt(((H+c0.*w1.*the2+b(i)).*w0.*the2)./(s.*alpha0.*del.*(1-rho(i)).*rho(i)+(H+c0.*w1.*the2).*rho(i).*{2}).*(H+c0.*w1.*the2+b(i)));
Dyuman Joshi
Dyuman Joshi 2022-7-1
编辑:Dyuman Joshi 2022-7-1
q(i)=sqrt(((H+c0.*w1.*the2+b(i)).*w0.*the2)./(s.*alpha0.*del.*(1-rho(i)).*rho(i)+(H+c0.*w1.*the2).*rho(i).*{2}).*(H+c0.*w1.*the2+b(i)))
Check the bold part. Why is 2 put in curly brackets?
Same is done for TC(i) as well.

请先登录,再进行评论。

回答(1 个)

Krishna
Krishna 2022-7-1
Hey Rameswari,
You are facing the issue in this line.
q(i)=sqrt(((H+c0.*w1.*the2+b(i)).*w0.*the2)./(s.*alpha0.*del.*(1-rho(i)).*rho(i)+(H+c0.*w1.*the2).*rho(i).*{2}).*(H+c0.*w1.*the2+b(i)));
and
TC(i)=c.*lambda(i)+y.*(a.*log(k0./k)+b(i).*log(beta0./beta))+(q(i)./2.*rho(i)).*((s.*alpha0.*del.*(1-rho(i)).*rho(i))+(H+c0.*w1.*the2).*rho(i).^{2}.*b(i).^{2}+((b(i).*((H+c0.*w1.*the2).*rho(i)).^{2})./(H+c0.*w1.*the2+b(i))).^{2})+(c0.*w0.*the2./q(i))
Check the following link:
Also follow this tutorial to get better response in Matlab Answers:

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

产品


版本

R2009b

Community Treasure Hunt

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

Start Hunting!

Translated by