[Matlab] practice_5

dewdew·2023년 7월 2일
0

Matlab & Simulink

목록 보기
4/6
post-thumbnail

% % x = 0 : 0.1 : 6pi;
% % y = sin(x);
% % plot(x, y)
% % title('sinusoid')
% % xlabel('time')
% % ylabel('magnitude')
% % grid
% % % text(7, 0, 'zero')
% % % gtext('peak') % 마우스 작업을 동반(gui)
% % % % plot(x) % y축 값으로 인식
% % % % plot(y)
% %
% % axis([2 22 -2 0.8]) % xmin xmax ymin ymax
% % v = axis
% % axis manual
% % axis equal
% % axis auto
% % axis off
% % axis on
% % % help axis
% %
% % plot(x, y, '--')
% % plot(x, y, ':')
% % plot(x, y, '.') % data point
% % plot(x, y, '-o')
% % plot(x, y, 'r')
% % plot(x, y, 'r.-') % line & marker
%
% % multiple graph
% % help plot
% % hold on
% % plot(x, y+1)
% % plot(x, x+y)
% % hold off
% % plot(x, y, x, cos(x), x, sin(x)+cos(x))
% % legend('sin', 'cos', 'sum')
%
% % graph handle(low level)
% % b = plotyy(x, sin(x), x, 10000
cos(x))
% % get(b(1))
% % ylabel('y1')
% % set( get(b(2), 'ylabel'), 'string', 'y2')
%
% % subplot (row majored)
% x = 0 : 0.05 : 3.5;
% subplot(2, 2, 1)
% plot(x, sin(x))
%
% subplot(2, 2, 3)
% plot(x, cos(x))
%
% subplot(1, 2, 2)
% plot(x, exp(x))
% xlabel('time')
% grid
% subplot(2, 2, 1)
% xlabel('time')
% grid
%
% subplot(2, 2, 3)
% grid
% title('my')
%
% % figure (new window)
% figure(2)
% plot(x, cos(x)+1)
% figure
% plot(x, sin(x))
% grid
% close all
%
% plot(x, sin(x))
% % clf
%
% % NaN & Inf in plot
% x = -2pi : pi/100 : pi;
% y = tan(x);
% plot(x, y)
% i = abs(y) > 10; % logical indexing <<!!
% y(i) = 10
sign( y(i));
% y = y'
% plot(x, y)
% ylim([-11 11])
% y(i) = nan;
% plot(x, y)
% ylim([-11 11])
% grid
% % y에 nan 이 있으면 그 부분은 skip 한다.
%
% % log scale
% % 1. 아주 넓은 범위를 표현할 때
% % 2. log scale 에서 직선이 나타날 때
%
% x = 0 : 0.01 : 4;
% y = exp(x);
%
% plot(x, y)
% grid
% semilogx(x, y)
% grid
% semilogy(x, y)
% grid
% loglog(x, y)
% grid
%
% x = 0 : 0.1 : 10;
% plot(x, sin(x), x, cos(x))
%
% % graph handle
% % 씨발.. 학점 좆됐어ㅗㅗㅗ
% x = 0 : 0.01 : 20;
% h1 = plot(x, sin(x), x, cos(x))
% whos h1
% get(h1(1))
% set(h1(1), 'LineWidth', 4, 'LineStyle', ':')
% h2 = xlabel('time')
% get(h2)
% set(h2, 'Rotation', 90)
%
% gcf % figure
% gca % axis
% get(gca)
%
% % 1. ginput
% x = 0 : 0.1 : 10;
% % plot(x, sin(x), '-')
% % [xx, yy] = ginput(3) % gui
% % hold on
% % plot(xx, yy, 'o')
% % hold off
%
% % 2. data cursor : alt + clk
% % plot(x, sin(x), '-')
%
% % a = imread('figure_imag.jpg');
% % whos a
% % image(a)
% % axis off
%
% %[xp, yp] = ginput(2)
% x = 10/359(xp-34)
% y = -2/273
(yp-19) + 1
%
% a = imread('figure_imag.jpg');
% image(a)
% %[xp, yp] = ginput % clk 으로 image data axis 구하기
% whos xp yp
% x = 10/359(xp-34)
% y = -2/273
(yp-19) + 1
%
%
% % -----------------------------------
% % (xp1, x1), (xp2, x2) 두 점을 지나는 직선공식
% % x - x1 = (x2-x1/xp2-xp1) * (xp - xp1)
% % x1 = 0 x2 = 10
% % xp1 = 34 xp2 = 394
% % -----------------------------------
%
% figure
% figure(1)
% plot(xp, yp, 'o')
% image(a)
% hold on
% plot(xp, yp, 'o')
% figure(2)
% plot(x, y, 'o')
%
% c.type
% c.coeff
% cc = c.coeff
%
% xx = 0 : 0.1 : 10;
% yy = polyval(cc, xx)
% close all
% plot(x, y, 'o', xx, yy)

% % data statics
y = rand(50,1);
plot(y)
mean(y)
std(y)

% histogram
d = ceil(6*rand(600,1));
unique(d)
whos d
hist(d)
N = hist(d, 6)
sum(N)

% r1 = rand(10000, 1);
% hist(r1, 100) % 100 개로 나눠서

% help rand randn : 정규분포...
% r2 = 3 + 0.8 * randn(10000,1); hist(r2, 100)
% 3 : mean 0.8 : sigma

%2d histogram
x = 2 rand(1000,1); % 0<x<2
y = 4
rand(1000,1);

[X, Y, Z, xx, yy, zz, XX, YY, ZZ] = hist2real(x, y, 8, 12);
hold on
% plot(x, y, 'o')

sum(Z)
sum(sum(Z))

profile
연습장

0개의 댓글