FIC MATLAB 2019-1/Aula-16

De MediaWiki do Campus São José
Revisão de 21h53min de 9 de maio de 2019 por Diegomedeiros (discussão | contribs) (Criou página com '<syntaxhighlight lang=matlab class="mw-collapsible"> % Importação de dados uiimport celula celula{1,:} = {} celula{2:end,:} VarName1(1,:) = [] Dez15(1,:) = [] whos tabela edit tabela tabela(1,...')
(dif) ← Edição anterior | Revisão atual (dif) | Versão posterior → (dif)
Ir para: navegação, pesquisa
% Importação de dados
uiimport
celula
celula{1,:} = {}
celula{2:end,:}
VarName1(1,:) = []
Dez15(1,:) = []
whos tabela
edit
tabela
tabela(1,:)
tabela(1,:) = []
tabela(end+1,:) = 3
tabela(end+1,:) = table([1 2 3 4 5 6])
tabela(end+1,:) = table([1 2 3 4 5])
tabela(end+1,:) = table(1,2,3,4,5)
tabela
tabela(4,2)
table('campo1',[1 2],'campo 2',[3 4])
table('campo1',[1 2],'campo2',[3 4])
table([1 2],[3 4])
table([1 2],[3 4],'RowNames',{'Variável 1','Carro'})
table([1 2],[3 4],'VariableNames',{'Variável 1','Carro'})
table([1 2],[3 4],'VariableNames',{'Variável1','Carro'})
table([1 2],[3 4],'VariableNames',{'Variavel1','Carro'})
tabela
tabela{4,2}
tabela{4,2}{:}
tabela
tabela(4,2)
tabela{4,2}
tabela
tabela(end+1,:) = {'teste', 1 2 3 4}
tabela(end+1,:) = {'teste', 1, 2, 3, 4}
tabela{end+1,:} = {'teste', 1, 2, 3, 4}
tabela(end+1,:) = {{'teste'}, 1, 2, 3, 4}
% Gráficos em 2D
x = -5:0.01:5;
y = x .^ 3;
figure
plot(x,y)
stem(x,y,'Marker','none')
bars(x,y)
bar(x,y)
stem(x,y,'Marker','x')
stem(x,y,'Marker','o')
stem(x,y,'Marker','none')
w = 0:10000;
h = 1 ./ (sqrt(1 + w.^2));
plot(w,h)
axis([-100 10000 0 1])
axis([-1000 10000 0 1])
axis([-1000 10000 -0.1 1])
semilogx(w,h)
semilogy(w,h)
loglog(w,h)
title('Gráfico incrível do Roberto')
xlabel('\omega')
ylabel('H(\omega)')
grid minor
grid on
grid minor
grid on
grid minor
g = loglog(w,h);
g = figure;
loglog(w,h)
title('Gráfico incrível do Roberto')
xlabel('\omega')
ylabel('H(\omega)')
grid on
whos g
saveas(g,'Nome da figura do Roberto.png')
figure(g)
w = logspace(-1,4,10000);
h = 1 ./ (sqrt(1 + w.^2));
loglog(w,h)
title('Gráfico incrível do Roberto')
xlabel('\omega')
ylabel('H(\omega)')
grid on
w = logspace(-4,4,100);
h = 1 ./ (sqrt(1 + w.^2));
loglog(w,h)
title('Gráfico incrível do Roberto')
xlabel('\omega')
ylabel('H(\omega)')
grid on
% Comando polar
o = 0:0.01:8*pi;
m = linspace(1,0,length(o));
polar(o,m)
z = 1 + j2
z = 1 + 2j
m = abs(z);
o = angle(z);
polar(o,m,'x')
k = 4;
theta = 0:0.1:8*pi;
p = cos(k*theta);
polar(theta,p)
theta = 0:0.1:2*pi;
p = cos(k*theta);
polar(theta,p)
theta = 0:0.001:2*pi;
polar(theta,p)
p = cos(k*theta);
polar(theta,p)
% PlotYY
figure
plot(w,h)
plot(x,y)
hold on
plot(theta,p)
figure
plotyy(x,y,theta,p)
close all
plotyy(x,y,'--d',theta,p,'o')
clear all
% Gráficos de linha em 3D
a = 1;
b = 2;
t = 0:0.01:8*pi;
x = a*cos(t);
y = a*sin(t);
z = b*t;
plot3(x,y,z)
grid minor
xlabel('x'); ylabel('y'); zlabel('z')
view(90,0)
figure
zlabel('z')
xlabel('x')
ylabel('y')
zlabel('z')
plot3(0,0,0)
grid on
grid minor
% Gráficos de superfície
[X,Y] = meshgrid(-20:0.5:20);
size(X)
size(Y)
X(1:10,1:10)
X(1:8,1:8)
Y(1:8,1:8)
R = sqrt(X.^2 + Y.^2) + 0.000000001;
Z = sin(R)./R;
size(Z)
surf(X,Y,Z)
xlabel('x'); ylabel('y'); zlabel('z')
i = 0; while true; view(i,48); i = mod(i+1,360); end
i = 0; while true; view(i,48); i = mod(i+1,360); pause(0.1); end
i = 0; while true; view(i,48); i = mod(i+1,360); pause(0.01); end
shading interp
light()
i = 0; while true; view(i,48); i = mod(i+1,360); pause(0.01); end
light(0,10)
light('Position',[0,10,2],'Style','local')
i = 0; while true; view(i,48); i = mod(i+1,360); pause(0.01); end
shading interp
i = 0; while true; view(i,48); i = mod(i+1,360); pause(0.01); end
i = 0; while true; view(i,-i); i = mod(i+1,360); pause(0.01); end
surf(X,Y,Z,'FaceLighting','gouraud','FaceColor','interp',...
'AmbientStrength',0.5)
light('Position',[-1 0 0],'Style','local')
i = 0; while true; view(i,-i); i = mod(i+1,360); pause(0.01); end
shading interp
i = 0; while true; view(i,40); i = mod(i+1,360); pause(0.01); end
mesh(X,Y,Z)
help shading
surf(X,Y,Z,'FaceLighting','gouraud','FaceColor','interp',...
surf(X,Y,Z,'FaceLighting','gouraud','FaceColor','interp')
shading flat
shading faceted
shading interp
mesh(X,Y,Z)
x = imread('imagem1.jpeg');
imshow(x)
i = 0; while true; view(i,40); i = mod(i+1,360); pause(0.01); end
i = 0; while true; view(i,-i); i = mod(i+1,360); pause(0.01); end
contour(X,Y,Z)
i = 0; while true; view(i,-i); i = mod(i+1,360); pause(0.01); end
%-- 09-05-2019 21:24:46 --%
mod(1:10,6)
[X,Y] = meshgrid(-20:0.5:20);
R = sqrt(X.^2 + Y.^2) + 0.000000001;
Z = sin(R)./R;
surfc(X,Y,Z)
a = 1;
b = 2;
x = a*cos(t);
t = 0:0.01:8*pi;
x = a*cos(t);
y = a*sin(t);
z = b*t;
k = 4;
theta = 0:0.001:2*pi;
p = cos(k*theta);
polar(theta,p)
i = 0; while true; view(i,-i); i = mod(i+1,360); pause(0.01); end
i = 0; while true; view(i,0); i = mod(i+1,360); pause(0.01); end
i = 0; while true; view(i,90); i = mod(i+1,360); pause(0.01); end