I want to plot a function of two variables

조회 수: 10 (최근 30일)
NooshinY
NooshinY 2017년 12월 1일
편집: Mukul Rao 2017년 12월 5일
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));

답변 (1개)

Mukul Rao
Mukul Rao 2017년 12월 4일
Hi, to clarify, are you trying to plot a series of different "f" values for different input "x" values?
  댓글 수: 2
NooshinY
NooshinY 2017년 12월 4일
yes exactly when f is a complicated function of X= x(1) and x(2)
Mukul Rao
Mukul Rao 2017년 12월 4일
편집: Mukul Rao 2017년 12월 5일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by