Help generating plot of Zakharov's function
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi guys,
I have a problem that is probably quite simple but I have been pulling my hair out for a while. I looking for a method of reliably plotting the zakharov function with x constrained to -5 >= x <= 5. Here's what I have so far:
[x,y] = meshgrid(-5:0.1:5,-5:0.1:5);
z = @zakharov;
figure
[C,h] = contour(x,y,z);
I'm having difficulty translating what is in the zakharov.m file to a vectorized form, that produces a grid of the correct size for surf and contour to plot. If possible I would really appreciate a method that I could generalize to multiple dimensions, and use on other built-in optimization functions like schaffers or rastrigins, as I want to try to use them to plot the results from genetic algorithms using these functions as the search space.
Any help on this would be very much appreciated!! Thanks in advance!
Jay
0 commentaires
Réponse acceptée
Thorsten
le 2 Déc 2014
x = -5:0.1:5; y = x;
for i = 1:numel(x), for j=1:numel(y), Z(j,i) = zakh([x(i) y(j)]); end; end
[X Y] = meshgrid(x, y);
surfl(X,Y,Z)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Genetic Algorithm dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!