Clear Filters
Clear Filters

How could i run the loop?

3 views (last 30 days)
M.Rameswari Sudha
M.Rameswari Sudha on 1 Jul 2022
Edited: Dyuman Joshi on 1 Jul 2022
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 Comments
M.Rameswari Sudha
M.Rameswari Sudha on 1 Jul 2022
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 on 1 Jul 2022
Edited: Dyuman Joshi on 1 Jul 2022
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.

Sign in to comment.

Answers (1)

Krishna
Krishna on 1 Jul 2022
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:

Tags

Products


Release

R2009b

Community Treasure Hunt

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

Start Hunting!