柚子_MATLAB
- 數(shù)據(jù):這里準(zhǔn)備的是兩個(gè)3行125列的矩陣~
-
主要用于對(duì)比不同參數(shù)下的測(cè)量數(shù)據(jù)值及其誤差值,最終繪制的數(shù)據(jù)真實(shí)值圖及柱狀誤差圖如下所示:
數(shù)據(jù)真實(shí)值圖及柱狀誤差圖
- MATLAB代碼:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 誤差柱狀圖
clc;clear;close all;
load .\數(shù)據(jù)\b; % 導(dǎo)入.mat數(shù)據(jù) 3行125列 測(cè)量值
load .\數(shù)據(jù)\c; % 導(dǎo)入.mat數(shù)據(jù) 3行125列 誤差值
figure()
subplot(2,1,1);
plot(abs(b(1,1:25)),'k^','MarkerFace','k','MarkerSize',3);
hold on
plot(abs(b(2,1:25)), 'ks','MarkerSize',3);
hold on
plot(abs(b(3,1:25)), 'ro','MarkerFace','r','MarkerSize',3);
legend('方法1','方法2','方法3','location','Northwest');
xlabel('xlabel(單位)');
ylabel('ylabel(單位)');
axis([0 26 -1 30]); % x軸與y軸的顯示范圍
set(gcf,'unit','centimeters','position',[0,0,20,15]);% 圖形位置0行0列 圖形大小 20*15
set(gca,'FontSize',12);
subplot(2,1,2);
bar(c(1,1:25),'k');
hold on
bar(c(2,1:25),'w');
hold on
bar(c(3,1:25), 'r');
legend('方法1','方法2','方法3','location','Northwest');
xlabel('xlabel(單位)');
ylabel('ylabel(單位)');
axis([0 26 0 20]);
set(gcf,'unit','centimeters','position',[0,0,20,15]);% 圖形位置0行0列 圖形大小 20*15
set(gca,'FontSize',12);
柚子_MATLAB