Plot 100 random points in 2-D equations
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
user1030mat
le 7 Déc 2019
Commenté : Lutfun Nahar
le 4 Juin 2020
I have the two following equations in 2-D plane:
g1=1/(6*pi) * exp( (((x1-4)^2 + (x2-11)^2) / 6)*0.6)
g2=1/(6*pi) * exp( (((x1-10)^2 + (x2-3)^2) / 6)*0.4)
I want to sample 100 points from each of the two equations and plot them in one graph..Any ideas?
0 commentaires
Réponse acceptée
Image Analyst
le 7 Déc 2019
Try this:
% Get a set of random x1 and x2 for g1.
x1 = rand(100, 1);
x2 = rand(100, 1);
g1 = 1 ./ (6*pi) * exp( (((x1-4) .^2 + (x2-11).^2) / 6)*0.6)
subplot(3, 1, 1);
plot(g1, 'r*', 'LineWidth', 2, 'MarkerSize', 10);
grid on;
title('g1', 'FontSize', 20);
% Get a NEW set of random x1 and x2 for g2.
g2 = 1 ./ (6*pi) * exp( (((x1-10).^2 + (x2- 3).^2) / 6)*0.4)
subplot(3, 1, 2);
plot(g2, 'b.', 'LineWidth', 2, 'MarkerSize', 20);
grid on;
title('g2', 'FontSize', 20);
% Now plot both on the same plot.
subplot(3, 1, 3);
plot(g1, 'r*', 'LineWidth', 2, 'MarkerSize', 10);
hold on;
plot(g2, 'b.', 'LineWidth', 2, 'MarkerSize', 10);
grid on;
title('Both g1 and g2', 'FontSize', 20);
5 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Axis Labels 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!