How can I make matrix choose?

조회 수: 1 (최근 30일)
Mahmoud Sami
Mahmoud Sami 2018년 10월 21일
댓글: Mahmoud Sami 2018년 10월 21일

I had a function get me variable m like that

  • m=[60;90;90;180;125.3;90;60;45;135]
  • and I need N to change when m changes.
  • When m=0 or 180 N=0
  • When m=90 N=1
  • when m=45 or 135 N=0.5
  • Otherwise P =5.
  • N and P are matrices not just value because it will be used in other equations.

채택된 답변

madhan ravi
madhan ravi 2018년 10월 21일
편집: madhan ravi 2018년 10월 21일
>> m=[60;90;90;180;125.3;90;60;45;135]
N=zeros(1,numel(m)); % your N should be here instead of this
N(m==0 | m==180)=0;
N(m==90)=1;
N(m==45 | m==135)=0.5;
N = N'
m =
60.0000
90.0000
90.0000
180.0000
125.3000
90.0000
60.0000
45.0000
135.0000
N =
0
1.0000
1.0000
0
0
1.0000
0
0.5000
0.5000
>>
  댓글 수: 23
madhan ravi
madhan ravi 2018년 10월 21일
its ok it happens you will improve sooner :) , explain with steps what you are trying to achieve lets debug together
Mahmoud Sami
Mahmoud Sami 2018년 10월 21일
My master is to get optimization for cost in a piping design system. The cost of piping depends on piping weight. So the piping lenght,diameter and other components is the major items L, OD, N. So I need to know the shortest path, then optimize the diameter and calculate the cost. N is no of elbows in system the degree of elbows affects cost as it affect industry. So need to change the angle between segments to 90 or 45 and minimize no. Of elbows also. The penalty fcn for genetic algorithms is to put penalty to cost if ang is not 90 or 45. To make the optimization not choose it. That's in simple way.

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by