フィルターのクリア

Can anyone help me ?

1 回表示 (過去 30 日間)
Muhammad Hafiz
Muhammad Hafiz 2017 年 11 月 2 日
コメント済み: Image Analyst 2017 年 11 月 3 日

I have a problem with my code, can you find a solution for this code?

I want to take one of the Position and Cost From Dance.Sector1.Position and Cost ...

But, I didn't understand the last code. Can anyone help me :(

if Scout.Position(i,1) <= qrmax && Scout.Position(i,1) >= 0  
      if Scout.Position(i,2) <= qrmax && Scout.Position(i,2) >= 0
     Dance.Sector1.Position(i,:) = Scout.Position(i,:);
     Dance.Sector1.Cost(i,:) = Scout.Cost(i,:);
     Dance.Sector1.Position = Dance.Sector1.Position(all(Dance.Sector1.Position ~= 0,2),:);
     Dance.Sector1.Cost = Dance.Sector1.Cost(all(Dance.Sector1.Cost ~= 0,2),:);
      end               
  end
    if Scout.Position(i,1) <= qrmax && Scout.Position(i,1) >= 0  
        if Scout.Position(i,2) >= qrmin && Scout.Position(i,2) <= 0
       Dance.Sector2.Position(i,:) = Scout.Position(i,:);
       Dance.Sector2.Cost(i,:) = Scout.Cost(i,:);
       Dance.Sector2.Position = Dance.Sector2.Position(all(Dance.Sector2.Position ~= 0,2),:);
       Dance.Sector2.Cost = Dance.Sector2.Cost(all(Dance.Sector2.Cost ~= 0,2),:);
        end
    end
    if Scout.Position(i,1) >= qrmin && Scout.Position(i,1) <= 0  
        if Scout.Position(i,2) >= qrmin && Scout.Position(i,2) <= 0  
       Dance.Sector3.Position(i,:) = Scout.Position(i,:);
       Dance.Sector3.Cost(i,:) = Scout.Cost(i,:);
       Dance.Sector3.Position = Dance.Sector3.Position(all(Dance.Sector3.Position ~= 0,2),:);
       Dance.Sector3.Cost = Dance.Sector3.Cost(all(Dance.Sector3.Cost ~= 0,2),:);
        end      
    end
    if Scout.Position(i,1) >= qrmin && Scout.Position(i,1) <= 0  
        if Scout.Position(i,2) <= qrmax && Scout.Position(i,2) >= 0  
       Dance.Sector4.Position(i,:) = Scout.Position(i,:);
       Dance.Sector4.Cost(i,:) = Scout.Cost(i,:);
       Dance.Sector4.Position = Dance.Sector4.Position(all(Dance.Sector4.Position ~= 0,2),:);
       Dance.Sector4.Cost = Dance.Sector4.Cost(all(Dance.Sector4.Cost ~= 0,2),:);
        end      
    end
    if Dance.Sector1.Cost < GlobalBest.Cost       
       GlobalBest.Cost=Dance.Sector1.Cost;
       GlobalBest.Position=Dance.Sector1.Position;
    end
    end	

The last if statement is my problem :(

回答 (1 件)

Image Analyst
Image Analyst 2017 年 11 月 2 日
It's saying if the current cost is less than the master, overall, global cost, then replace the master, overall, global cost with the current cost. And also to record/log the position where that occurred. This will let you examine all the costs and find the overall lowest cost.
  2 件のコメント
Muhammad Hafiz
Muhammad Hafiz 2017 年 11 月 3 日
編集済み: Muhammad Hafiz 2017 年 11 月 3 日
yes I know ... but at the end if statement I have an error :(
this is the error message (Reference to non-existent field 'Cost'.)
Image Analyst
Image Analyst 2017 年 11 月 3 日
Well, there is no Cost field. Put a breakpoint there and then when it stops, examine the variable in the variable editor to see what fields it does have.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeModeling についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by