Matlab繪圖-讀取文件並進行曲線繪製

一、文件讀取

文件保存成csv,或者txt,逗號分割;

res = readtable('/User/xxx/path/file.csv')
size = height(res)

二、繪製曲線

figure(1)
plot(res.x1(start_index:end_time),res.y1(start_index:end_time),'r-*','MarkerSize',5)
hold on
plot(res.x2(start_index:end_time),res.y2(start_index:end_time),'b--*','MarkerSize',3)

legend("Curve1","Curve2")
set(gca,'FontSize',14);
hold off

曲線顏色:r,b,k,c,g,y,,,

曲線形式:默認實線,--虛線,*,p,o標記

曲線粗細:‘MarkerSize’

字體設置:set(gca,'FontSize',14);

 

其他:

獲取matlab的table文件中某個元素的索引方法:

start_index = find(res.x1(:)==point);

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章