matlab讀檔畫圖

May 5, 2011 at 5:53 pm (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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.