top of page

Octave practice :: Plotting Data

  • 작성자 사진: Soojin Woo
    Soojin Woo
  • 2020년 4월 30일
  • 1분 분량
Contents in the post based on the free Coursera Machine Learning course, taught by Andrew Ng.

1. define a matrix

>> t = [0:0.01:0.98];
ree
Matrix t

2. plot

>> y1 = sin(2*pi*4*t)
>> plot(t,y1);
ree
plot(t,y1);

>> y2 = cos(2*pi*4*t)
>> plot(t,y2);
ree

3. hold on

>> plot(t,y1);
>> hold on;
>> plot(t,y2);
ree

3.1 How to apply assigned color

>> plot(t, y1,'g');
>> hold on;
>> plot(t,y2,'y');
ree

4. label

ree

4.1 xlabel

>> xlabel('time')
ree

4.2 ylabel

>> ylabel('value')
ree

5. legend

>> legend('sin', 'cos')
ree

6. title

>> title('my plot')
ree

7. save

>> print -dpng 'myPlot.png'
ree

8. figure

>> figure(1); plot(t,y1);
ree

>> figure(2); plot(t,y2);
ree

9. subplot

>> subplot(1,2,1);
ree

>> plot(t,y1);
ree

>> subplot(1,2,2);
ree

>> plot(t,y2);
ree

9.1 In the case of using subplot(1,2,2) first. (<-> Above we applied subplot(1,2,1) first)

>> subplot(1,2,2);
ree

10. axis

>> axis([0.5 1 -1 1])
ree

11. clf

ree

12. imagesc

12.1 magic

>> A=magic(5)
ree

12.2 imagesc

>> imagesc(A)
ree

12.3 colorbar & colormap

>> imagesc(A), colorbar, colormap gray

- You could compare colormap to matrix A. It shows that a smaller number is related to a darker color on the map. - For example, Look at A(1,3) = 1. And we can verify that it matches with one of the darkest parts.

ree

13. Comma VS Semicolon

>> a=1, b=2, c=3
a = 1
b = 2
c = 3
>> a=1;b=2;c=3;
>>

- By using 'Comma' you can carry out multiple commands simultaneously.

댓글


SUBSCRIBE VIA EMAIL

  • Youtube
bottom of page