How to plot 2 D powell function with the code given below?

조회 수: 1 (최근 30일)
huma
huma 2017년 4월 23일
편집: amine&& 2017년 4월 25일
% code
function y = powell(x)
%
% Powell function
% Matlab Code by A. Hedar (Nov. 23, 2005).
% The number of variables n should be adjusted below.
% The default value of n = 24.
%
n = 24;
m = n;
for i = 1:m/4
fvec(4*i-3) = x(4*i-3)+10*(x(4*i-2));
fvec(4*i-2) = sqrt(5)*(x(4*i-1)-x(4*i));
fvec(4*i-1) = (x(4*i-2)-2*(x(4*i-1)))^2;
fvec(4*i) = sqrt(10)*(x(4*i-3)-x(4*i))^2;
end;
fvec = fvec';
y = norm(fvec)^2;

답변 (2개)

amine&&
amine&& 2017년 4월 23일
Hello, if you have a function like
function y = powell(x)
y = x+1;
you can use,
f=@(x)powell(x);
fplot(f)

huma
huma 2017년 4월 24일
Thanks for ur suggestion but i needed a surface plot.If you could help me with that it would be great help.
  댓글 수: 1
amine&&
amine&& 2017년 4월 25일
편집: amine&& 2017년 4월 25일
What do you mean by surface plot. Your function contains only one output then you can not desin a surface plot.

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

카테고리

Help CenterFile Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by