フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Hello guys, please help me to solve the below mentioned prograame. it is not running

1 回表示 (過去 30 日間)
adarsh
adarsh 2018 年 1 月 19 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
D1=2;
D2=3;
D3=5;
Q1=4;
Q2=5;
Q3=6;
V1=4*Q1/(3.14*D1^2);
V2=4*Q2/(3.14*D2^2);
V3=4*Q3/(3.14*D3^2);
P1=5*D1^2;
P2=5*D2^2;
P3=0.5*D3^2;
if Vi<=10
Cpv=0;
else
for i=1:3
Cpv=(1/15)*(Vi^2-100);
end
end
%%%%
if Pj>=18
Cpp=0;
else
for j=1:3
Cpp=Cpp+18-Pj;
end
end
Comment on this Answer
  2 件のコメント
Birdman
Birdman 2018 年 1 月 19 日
What do you want this code to do?
adarsh
adarsh 2018 年 1 月 19 日
i want to get the value of: f=Cpv+CPP

回答 (2 件)

Image Analyst
Image Analyst 2018 年 1 月 19 日
You need to define Vi and Pj. For example:
Vi = 5
Pj = 22
or whatever. If you do that, it runs.
  7 件のコメント
Walter Roberson
Walter Roberson 2018 年 1 月 20 日
Your objective function is going to receive a vector of values in a single variable. Extract portions of that vector into variables inside the function. Use vectors and index them as needed.
adarsh
adarsh 2018 年 1 月 20 日
kindly send a small example

Walter Roberson
Walter Roberson 2018 年 1 月 20 日
function cost = obj(x)
P = x(1:10) ;
V = x(11:18);
cost = sum((P-7).^2) + sum((V-100).^2) ;
  6 件のコメント
adarsh
adarsh 2018 年 1 月 20 日
is now the way correct. I have put indices on each letter. How to write and correlate the summation and if- else statement in the program.
Jan
Jan 2018 年 2 月 22 日
@adarsh: Do not let the expression "Q1,Q2,Q3, ..." confuse you. Later in the document Q is an array and an index is used: Q(1), Q(2), ... Using vectors is the right way to go.

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by