フィルターのクリア

why does my figure doesn't show

3 ビュー (過去 30 日間)
lucky_
lucky_ 2016 年 1 月 21 日
コメント済み: Star Strider 2016 年 1 月 21 日
I have data points 1000 and for the first 1000 I'm using mean [-2 1] and std of 0.85 and for the other 1000 I'm using mean [4 5] and std 2 and I'm trying to plot the data but I'm getting this error
function kmean( )
data1 = 1000;
s =[-4 0;1 0.75];
a =[3 0;4 2.0];
data3 = s * data1;
data4 = a * data1;
figure
plot(data3(:,1) , data3(:,2) , 'r.');
plot(data4(:,1) , data4(:,2) , 'g.');
xlabel('x-value');
ylabel('y-value');
axis square
axis ([-10 10 -10 10])
end

採用された回答

Star Strider
Star Strider 2016 年 1 月 21 日
My guess is that the ‘data3’ plot doesn’t show.
There are two ways to correct that:
1. Use the hold function:
figure
plot(data3(:,1) , data3(:,2) , 'r.');
hold on
plot(data4(:,1) , data4(:,2) , 'g.');
hold off
xlabel('x-value');
ylabel('y-value');
axis square
axis ([-10 10 -10 10])
2. Plot two separate figures:
figure(1)
plot(data3(:,1) , data3(:,2) , 'r.');
xlabel('x-value');
ylabel('y-value');
axis square
axis ([-10 10 -10 10])
figure(2)
plot(data4(:,1) , data4(:,2) , 'g.');
xlabel('x-value');
ylabel('y-value');
axis square
axis ([-10 10 -10 10])
MATLAB will plot subsequent plot calls in the existing axes, overwriting the existing plot, unless you use the hold function.
  6 件のコメント
lucky_
lucky_ 2016 年 1 月 21 日
thank you very much this is what I was looking for your answers are always detailed and helped me a lot
Star Strider
Star Strider 2016 年 1 月 21 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by