How can I make graphs in Matlab?

97 Views Asked by At

For my thesis I have to include figures. I want to make a figure like the figure in the attachment, but since I am pretty new to Matlab I do not understand the best way (I know this may be a many covered question already, but I can not find the right answer for me). My y-axis has to be in the same manner as the y-axis in the picture from 0,05 - 1 - 10 - 100 - 1000 and so on. A small sample of my data with two lines is:

  1. C = 5 T1 = 7,414 T2 = 0,109
  2. C = 10 T1= 29,294 T2 = 0,218
  3. C = 15 T1 = 41,333 T2 = 0,109,
  4. and so on until
  5. C = 30 T1 = 1355,45 T2 = 0,515

In another figure I want to do the same thing, but with the x-axis values not as nicely arranged, and my y-axis has to be in the same manner as the second attachment: 0,05 - 1 - 10 - 20 - 30 - 40 - 50 - 60 - 70:

  1. G = 250 T1= 30,426 T2= 0,109
  2. G=275 T1= 41,333 T2=0,109
  3. G=300 T1= 45,966 T2 = 0,125
  4. G=350 T1=51,71 T2 = 0,109 5.G = 400 T1= 66,035 T2 = 0,125

Can someone tell me how I should make the two figures?
http://nl.mathworks.com/matlabcentral/answers/229354-how-can-i-make-graphs-in-matlab

1

There are 1 best solutions below

0
On

Actually, it's ambiguous what you want exactly. However, I tried to write some Matlab code (I am not the best in programming, but I tried since to no answers):

clc;clear;close

k = 6;
x = 1:k;
T1 = 100 * rand(1,k); % creating 6 random T1 - values 
T2 = 50 *rand(1,k);   % creating 6 random T2 - values

hold on

plot(x,T1,'-o')
plot(x,T2,'-*r')

%% Manipulating x - axis
ax = gca;
ax.XTick = x;

C = cell(1,length(x));
for i = 1:length(x)
    C{i} = sprintf('%u', 5 * i);
end
ax.XTickLabel = C;

%% Manipulating y - axis
ytick = zeros(1,5);
max = max( [max(T1) max(T2)] );
min = min( [min(T1) min(T2)] );
d = (max - min)/4;

for j = 0:4
    ytick(1,j+1) = min + j * d;
end
ax.YTick = ytick;
ax.YTickLabel = {'0.05','1','10','100','1000'};

%% Figure Options
title('Add a title')
legend('(x,T1) graph','(x,T2) graph','Location','northwest')
xlabel('Label of x - axis ')
ylabel('Label of y - axis')

hold off

which produces something like that:

enter image description here