x1 = [-4.2 -2.6 -1 0.6 2.2 3.8 5.4 7 8.6]
x2 = [0.8 2.4 4 5.6 7.2 8.8 10.4 12 13.6]
function Y = objectivefunction (X)
x1
x2
a = 1;
b = 5.1/(4*pi^2);
c = 5/pi;
r = 6;
s = 10;
t = 1/(8*pi);
Y = a*(x2 - b*x1^2 + c*x1 - r)^2 + s*(1-t)*cos(x1) + s
end
[-4.2 0.8], [-4.2 2.4],[-4.2 4],[-4.2 5.6],[-4.2 7.2],[-4.2 8.8],[-4.2 10.4],[-4.2 12],[-4.2 13.6]
[-2.6 0.8],[-2.6 2.4],[-2.6 4],[-2.6 5.6] , ...
I want to put all the x2 values in one x1 value sequentially.
Please let me know! Thank you!

 採用された回答

Walter Roberson
Walter Roberson 2021 年 6 月 2 日

0 投票

x1 = [-4.2 -2.6 -1 0.6 2.2 3.8 5.4 7 8.6];
x2 = [0.8 2.4 4 5.6 7.2 8.8 10.4 12 13.6];
[X1, X2] = meshgrid(x1, x2);
pairs = [X1(:), X2(:)];
pairs(1:12,:)
ans = 12×2
-4.2000 0.8000 -4.2000 2.4000 -4.2000 4.0000 -4.2000 5.6000 -4.2000 7.2000 -4.2000 8.8000 -4.2000 10.4000 -4.2000 12.0000 -4.2000 13.6000 -2.6000 0.8000

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeAndroid Devices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by