I want to plot a function of two variables
1 回表示 (過去 30 日間)
古いコメントを表示
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));
0 件のコメント
回答 (1 件)
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 件のコメント
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 Center および File Exchange で Bar Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!