>> A = magic(3) A = 8 1 6 3 5 7 4 9 2 >> I = A > 5 I = 1 0 1 0 0 1 0 1 0 >> whos Name Size Bytes Class Attributes A 3x3 72 double I 3x3 9 logical여기서 I 값의 1은 True, 0은 False를 나타낸다.
%% find 함수 사용 A = magic(3) A(find(A>5)) = 100 %% A 내부의 값이 5보다 큰 경우에 100으로 변경 A = magic(3) A(A>5) = 100
A = 8 1 6 3 5 7 4 9 2 A = 100 1 100 3 5 100 4 100 2
x = 0:0.1:3; %x값을 0에서 3까지 0.1씩 증가시킨다. y = sin(x).* (x>0 & x<=1) + exp(-x).*(x>1 & x<=2) + 3*(x>2) plot(x,y)
str1 = 'what''s your name?' str2 = 'My name is xxx' str4 = [srt1 ' ' str2] char(str1, str2)
>> pi ans = 3.1416 >> format long >> pi ans = 3.141592653589793 >> 2*12.3 ans = 24.600000000000001 >> format >> pi ans = 3.1416 >> single(pi) ans = 3.1416 >> format long >> single(pi) ans = 3.1415927
>> format bank >> 1 ans = 1.00분수로 수를 표현하는 format
>> format rat >> pi ans = 355/113
>> A = magic(4) A = 16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1 >> A(:,:,2)=pascal(4) A(:,:,1) = 16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1 A(:,:,2) = 1 1 1 1 1 2 3 4 1 3 6 10 1 4 10 20 >> A(:,1,2) ans = 1 1 1 1 >> A(2,2,2) ans = 2
>> format compact >> A = cat(3, magic(3), pascal(3)) A(:,:,1) = 8 1 6 3 5 7 4 9 2 A(:,:,2) = 1 1 1 1 2 3 1 3 6
x{1,1} = 'matlab' x{1,2} = magic(4); x{2,1} = @sin; x{2,2} = struct('age', 20, 'sex', 'male'); cellplot(x, 'legend')
>> x{1} ans = matlab >> x{1,1} ans = matlab >> x{1,2} ans = 16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1 >> x{2,1} ans = @sin >> x{2,2} ans = age: 20 sex: 'male' >> x{1,2}(:,3) ans = 3 10 6 15
>> whos Name Size Bytes Class Attributes x 2x2 660 cellx{:} == x{1}, x{2},...
>> x x = 'matlab' [4x4 double] @sin [1x1 struct] >> x(:) ans = 'matlab' @sin [4x4 double] [1x1 struct] >> x{:} ans = matlab ans = @sin ans = 16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1 ans = age: 20 sex: 'male'
>> x(1,2) ans = [4x4 double] >> x{1,2} ans = 16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1데이터 밀어내기
>> x(end,:) = {123 @sin} x = 'matlab' [4x4 double] [ 123] @sin셀 삭제
>> x x = 'matlab' [4x4 double] [ 123] @sin >> x(end,:) = [] x = 'matlab' [4x4 double]