# Plot 100 random points in 2-D equations

5 ビュー (過去 30 日間)
user1030mat 2019 年 12 月 7 日
Commented: Image Analyst 2019 年 12 月 8 日
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 件のコメント

サインイン to comment.

### 採用された回答

Image Analyst 2019 年 12 月 7 日
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);

#### 2 件のコメント

user1030mat 2019 年 12 月 8 日
Why g2 in the graph "g1 and g2" are displayed all in the x axis ?
Image Analyst 2019 年 12 月 8 日
Why not? I think it's interesting to see how different their scales (ranges) are. If you don't want them plotted on the same chart, then don't. You can use separate charts (like the first two) if you want.

サインイン to comment.

### More Answers (0)

サインイン してこの質問に回答します。

Translated by