Question

Construct a MATLAB/EXCEL program that will perform a grid search on the region from 0< x<10 and 0y 10. Use this grid search
0 0
Add a comment Improve this question Transcribed image text
Answer #1

clear
clc

%% anonymously defining f(x,y) for easy usage in the entire program
f = @(x,y) x^4 + y^4 - 16*x^3 - 28*y^3 + 97*x^2 + 295*y^2 - 264*x -1386*y + 577;

%% defining the number of points or length (len) for x and y and the equally spaced values using linspace in the range [0 10]
xlen = 100; ylen = 100; % the larger the len the more accurate the results
x = linspace(0,10,xlen);
y = linspace(0,10,ylen);

%% initialising the solution xmin and ymin with the largest values possible and computing fmin at those values
xmin = max(x);
ymin = max(y);
fmin = f(xmin,ymin);

%% grid searching where every possible combination of x and y values is used to compute the value of f(x,y)
for i=1:xlen
for j=1:ylen
fvalue = f(x(i),y(j));
if fvalue<fmin % ensuring the search is kept moving towards the minimum direction
fmin = fvalue; %updating fmin with the current minimum value
xmin = x(i); ymin = y(j); %updating xmin and ymin
end
end
end

%% displaying results
disp('OPTIMUM RESULTS')
fprintf(['fmin: ' num2str(fmin) '\n'])
fprintf(['xmin: ' num2str(xmin) '\n'])
fprintf(['ymin: ' num2str(ymin) '\n'])

Add a comment
Know the answer?
Add Answer to:
Construct a MATLAB/EXCEL program that will perform a "grid search" on the region from 0< x<10...
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
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
ADVERTISEMENT