matlab讀檔畫圖
w = 0:1:150;
x1 = 1:1:151;
x2 = 1:1:151;
x3 = 1:1:151;
x4 = 1:1:151;
x1(1) = 0;
x2(1) = 0;
x3(1) = 0;
x4(1) = 0;
load o200.txt
load o300.txt
load o400.txt
load o500.txt
for i = 1:150
x1(i+1) = o200(i);
x2(i+1) = o300(i);
x3(i+1) = o400(i);
x4(i+1) = o500(i);
end
plot(w, x1, 'b:', w, x2, 'r--', w, x3, 'g-.', w, x4, 'y-');
title('Data confidentiality');
xlabel('Number of nodes compromised');
ylabel('Fraction of total compromised regarding data confidentiality');
grid on;
w:是圖表的X軸
x1,x2,x3 and x4這四個array分別要載入4個txt檔的數值。
matlab的array index是從1開始算起。
Advertisement