1) unique

returns only unique elements in array

ex)
A = ceil(6*rand(1000,1));
whos A
unique(A)
help unique

2) program file

extension : m
cannot create exe file (but possible using Matlab Coder)
either main program or function

① function
	how to tell : starts with "function"
    	how to run : need to provide - input data & variable names for outputs
        	ex) [a,b] = size(M)
② main
	how to tell : does not start with "function"
    	how to run : just type file name without .m

Input(keyboard) ⟹ program ⟹ Output(monitor)

3) input via keyboard

a = input('Type a -> ')
a = input('Type a \n 1:yes \n 0:no \n --> ')
s = input('Type your name : ','s') % string input without ' '

4) output via monitor

x = rand
x
disp(x) % 내용물만 보여줄 때, 더 깔끔하게 볼 수 있음
disp('Hello')
['answer : ',num2str(x),'rad/s']
disp(['answer : ',num2str(x),'rad/s'])

0개의 댓글