Question

Problem:

Plot the egg holder function and find the global optimizer in Matlab

Eggholder function:

Y= -(u2+47)*sin(sqrt(abs((u2)+(u1/2)+(47)))) - (u1)*sin(sqrt(abs((u1)-(u2+47))))

where u equals x

Below is my code and the picture of the graph I got. I know for a fact that it's wrong but don't know how to fix it.

Figure 1 Desktop File Edit Tools Window Help View Insert AE x105 1 0.5 0 -0.5 -1 600 400 600 200 400 200 -200 -200 -400 -400

<

x1=[-600:10:600];

x2=[-600:10:600];

[u1, u2] = meshgrid(x1, x2);

term1=-(u2+47)*sin(sqrt(abs((u2)+(u1/2)+(47))));

term2=-(u1)*sin(sqrt(abs((u1)-(u2+47))));

y=term1+term2;

figure

surf(u1,u2,y)

>

Please show all work and explain what you're doing so that I can understand the process.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

There is just slight modification in the code provided here. Since x1 and x2 are array, while multiplying, we have to use (.*) for element wise multiplication in the expression of term1 and term2.

Below is the corrected code :

%To create the meshgrid of two variables x1 and x2 varying from -600 to 600
%with an interval of 10
[x1, x2] = meshgrid(-600:10:600, -600:10:600);

%First Term of eggholder function
term1= -(x2+47).*sin(sqrt(abs((x2)+(x1/2)+(47))));
%Second Term of eggholder function
term2= -(x1).*sin(sqrt(abs((x1)-(x2+47))));

y=term1+term2;

figure
% Surface Plot
surf(x1,x2,y)
title('Eggholder Function')

Eggholder Function 1500 1000 500 0 -500 -1000 -1500 600 600 400 400 200 200 200 200 400 400 600 -600

Add a comment
Know the answer?
Add Answer to:
Problem: Plot the egg holder function and find the global optimizer in Matlab Eggholder function: Y=...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Can you please help me answer Task 2.b? Please show all work. fs=44100; no_pts=8192; t=([0:no_pts-1]')/fs; y1=sin(2...

    Can you please help me answer Task 2.b? Please show all work. fs=44100; no_pts=8192; t=([0:no_pts-1]')/fs; y1=sin(2*pi*1000*t); figure; plot(t,y1); xlabel('t (second)') ylabel('y(t)') axis([0,.004,-1.2,1.2]) % constrain axis so you can actually see the wave sound(y1,fs); % play sound using windows driver. %% % Check the frequency domain signal. fr is the frequency vector and f1 is the magnitude of F{y1}. fr=([0:no_pts-1]')/no_pts*fs; %in Hz fr=fr(1:no_pts/2); % single-sided spectrum f1=abs(fft(y1)); % compute fft f1=f1(1:no_pts/2)/fs; %% % F is the continuous time Fourier. (See derivation...

  • Game Description: Most of you have played a very interesting game “Snake” on your old Nokia...

    Game Description: Most of you have played a very interesting game “Snake” on your old Nokia phones (Black & White). Now it is your time to create it with more interesting colors and features. When the game is started a snake is controlled by up, down, left and right keys to eat food which appears on random locations. By eating food snake’s length increases one unit and player’s score increases by 5 points. Food disappears after 15 seconds and appears...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT