FIC-MATLAB-GABARITO1-SIM-SIM

De MediaWiki do Campus São José
Ir para navegação Ir para pesquisar
WARNING - Spoiler alert !
Abra por sua conta e risco

clear all; close all; clc

%% Questão 1 x = -2:0.001:2; f = sqrt(1 - (abs(x) - 1).^2); g = acos(1 - abs(x)) - pi; figure plot(x,f,'hr', x,g,'hr', 'LineWidth',4)

%% Questão 2 x = linspace(-4,4,1000); f = x.^2 + x - 2; figure plot(x,f) grid on hold on stem([-2 1],[0 0])

%% Questão 3 t = linspace(1,3,1000); T = 3 * log(2*t) - 5*exp(0.5*t); figure plot(t,T) title('Temperatura') xlabel('Tempo [minutos]') ylabel('° C')

%% Questão 4 x = linspace(0,2,1000); u = 100*log10(60*x + 1); v = 50*cos(6*x) .* sin(2*x) + 150*x; figure plot(x,u,'y','LineWidth',4) hold on plot(x,v,'Color',[0.952941179275513 0.87058824300766 0.733333349227905],'LineWidth',4) legend('Ferrari','Fusca') title('Alta velocidade é perigoso') ylabel('km/h')

%% Questão 5 x1 = linspace(0,2*pi,100); x2 = linspace(pi,3*pi,100); figure stem(x1,cos(x1)) hold on stem(x2,0.5*sin(x2))

%% Questão 6

figure

x = linspace(-pi,pi,2000); f = sign(x);

N = [1:5:100 100:-5:1];

for ii = 1:length(N)

   n = 1:2:N(ii);
   g = (4/pi) * sum(sin(n' * x) ./ (n' * ones(size(x))));
   
   plot(x,f)
   hold on
   plot(x,g)
   hold off
   
   legend('f(x)','g(x)')
   
   pause(0.005)
   

end


%% Questão 7 t1 = linspace(1,63,100); t2 = linspace(63,80,100); t3 = linspace(81,100,100); t4 = linspace(101,120,100);

figure

subplot(2,1,1) plot(t1,sin(2*pi*t1/63),'b',t2,zeros(size(t2)),'b',t3,ones(size(t3)),'b',t4,-ones(size(t4)),'b') title('Versão 1') xlabel('Tempo [s]') ylabel('Tensão [v]') grid minor ylim([-1.1 1.1])

subplot(2,1,2) plot(t1,sin(2*pi*t1/63),'b',t2,zeros(size(t2)),'b',[80 81],[0 1],'b',t3,ones(size(t3)),'b',[100 101],[1 -1],'b',t4,-ones(size(t4)),'b') title('Versão 2') xlabel('Tempo [s]') ylabel('Tensão [v]') grid minor ylim([-1.1 1.1])

</syntaxhighlight>