Plot 100 random points in 2-D equations

5 vues (au cours des 30 derniers jours)
user1030mat
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?

Réponse acceptée

Image Analyst
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);
0001 Screenshot.png
  5 commentaires
Image Analyst
Image Analyst le 3 Juin 2020
Move it from where to where?
Lutfun Nahar
Lutfun Nahar le 4 Juin 2020
I plotted only g2. Then want to move only one point randomly.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by