matlab畫圖,明明標記了11個點的坐標,最後畫出來的圖卻只有10個點,坐標沒有重疊。這是為什麼?
代碼如下:
x=[0.8615,0.8428,0.7852,0.7959,0.7918,0.7199,0.8623,0.7436,0.8691,0.7984,0.7917];
y=[0.1470903631684301,0.13116599942808133,-0.09434872748069782,-0.07797755218758937,-0.0986917357735202,-0.10401772948241352,0.15073634543894754,0.34390191592793823,0.1464290820703461,-0.09692236202459253,-0.09847726622819561];
scatter(x,y);
仔細數了,確實是11個坐標,但是最後畫出來的圖上只有10個點,坐標之間沒有重疊。到底是哪裡出問題了?新手,搞了半天沒頭緒。謝謝啦。
不好意思,我愛我的祖國。所以可能不符合題主的答題要求了啊,題主看到這裡理應把我拉黑不會往下看了吧。下邊就是給其他有興趣的人解釋一下:
題主的數據裡邊有兩個點非常接近:
0.7917 -0.0984772662281956
0.7918 -0.0986917357735202
所以可以用jitter:
x=[0.8615,0.8428,0.7852,0.7959,0.7918,0.7199,0.8623,0.7436,0.8691,0.7984,0.7917];
y=[0.1470903631684301,0.13116599942808133,-0.09434872748069782,-0.07797755218758937,-0.0986917357735202,-0.10401772948241352,0.15073634543894754,0.34390191592793823,0.1464290820703461,-0.09692236202459253,-0.09847726622819561];
scatter(x,y,"jitter","on","jitterAmount",1e-3);
初始的大圖對局部進行放大
或是改為
hold onfor ii=1:11scatter(x(ii),y(ii));end然後單步調試,可以很容易看出哪裡兩個點很接近推薦閱讀:
※(新手提問)matlab中@的含義?
※MATLAB中如何畫出下圖?文獻中的圖片如補充說明所示,謝謝。?
※matlab計算積分無解?
※matlab中有哪些有趣的命令?
※如何在 MATLAB 中實現車牌號圖片的識別?
TAG:MATLAB |