I want to plot a function of two variables

6 visualizzazioni (ultimi 30 giorni)
NooshinY
NooshinY il 1 Dic 2017
Modificato: Mukul Rao il 5 Dic 2017
Hi I want to find the plot of my function blow: for different x(1) and x(2). but I cannot do it. would anyone help me:
function f=optim(x)
H11=1.25;
H12=1.27;
x3=1.2;
CI=120;
Cp=90000000;
Cr=2000;
J=3;
m=1;
t1=zeros(1,J);
t2=zeros(1,J);
Inspcost1=zeros(1,J);
Inspcost2=zeros(1,J);
Inspcostall=zeros(1,J);
Downcost1=ones(1,J);
Down23=ones(1,J);
Lencycle1=zeros(1,J);
Downall1=ones(1,J);
%%expected value of number of inspection interval ( Inspection Inverval should be between [2.7,10])
for j=1:J % number of intervals
t1(j)=j*x(1)*10^(-1)+0.1;
t2(j)=(j-1)*x(1)*10^(-1)+0.1;
end
for j=1:J
Inspcost1(j)=Rel(x(2),x3,t1(j));
Inspcost2(j)=Rel(x(2),x3,t2(j));
Inspcostall(j)=j.*(Inspcost2(j)-Inspcost1(j));
end
Inspcost=CI*sum(Inspcostall);%%%%%first item in numerator
%%Excepted cycle length
for j=1:J
Lencycle1(j)=t1(j).*(Inspcost2(j)-Inspcost1(j));
end
Lenthcycle=sum(Lencycle1); %%%%%denominator
Totalcost=Inspcost+Cr; %%%%total numerator
f=(Totalcost/(Lenthcycle+50));

Risposte (1)

Mukul Rao
Mukul Rao il 4 Dic 2017
Hi, to clarify, are you trying to plot a series of different "f" values for different input "x" values?
  2 Commenti
NooshinY
NooshinY il 4 Dic 2017
yes exactly when f is a complicated function of X= x(1) and x(2)
Mukul Rao
Mukul Rao il 4 Dic 2017
Modificato: Mukul Rao il 5 Dic 2017
Thanks, when you say cannot do it in your original post, what do you mean? What have you tried so far? I would expect just evaluating the function at different x values either in a loop or with arraryfun should give you a vector of f values, which you can then plot easily using the standard plot syntax.

Accedi per commentare.

Categorie

Scopri di più su Graphics Performance in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by