簡體   English   中英

如何通過繪圖連接點

[英]How connect points by using plot

我的代碼的問題在於它繪制離散點而不將它們連接在一起。

相關代碼:

for i:1:100
    wx(i,1)= Related formula
    figure(1)
    plot(i,wx(i,1),'r.-')
    line(i,wx(i,1))
    axis([0,i,-10,10])
    hold on
end

結果顯示在下圖中;

如何將它們連接在一起?

如果在數組中輸入線的所有端點,則plot功能只能將點與線連接。 如果將它們一一發送,它將僅繪制離散點而不連接它們。 建議先計算數組中的所有點,然后再將所有點立即發送到plot函數。

這里最簡單的解決方案是:

for i = 1:100
  x(i) = i
  wx(i,1) = related_formula()
end

figure(1)
plot(x, wx(:,1), 'r.-')
axis([0,i,-10,10])
i =1:100;
wx=Related formula(i);
figure(1)
plot(i,wx,'r.-')
axis([0,i,-10,10])

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM