Matlab 2 Operaciones Con Vectores y Matrices
Matlab 2 Operaciones Con Vectores y Matrices
Matlab 2 Operaciones Con Vectores y Matrices
A=
-2 1
4 7
ans =
ans =
ans =
-2
>> A=[-2 14
1 5]
A=
-2 14
1 5
>> %Operación: Crea una matriz identidad y llena de ceros el resto d elas posiciones
>> A=eye(4,4)
A=
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
>> %Comando:ones
>> A=ones(4,5)
A=
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
>> %Comando:zeros
>> A=zeros(4,5)
A=
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
>> %Comando:rand
>> A=rand(2,2)
A=
0.8147 0.1270
0.9058 0.9134
>> %Comando:linspace
>> A=linspace(1,1)
A=
Columns 1 through 15
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Columns 16 through 30
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Columns 31 through 45
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Columns 46 through 60
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Columns 61 through 75
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Columns 76 through 90
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
>> %Comando:A+B
A=
-2 3
-4 5
-6 7
>> B=[1 1; 2 0; 6 2]
B=
1 1
2 0
6 2
>> A+B
ans =
-1 4
-2 5
0 9
>> %Comando:C^2
>> C=[2 1; 1 3]
C=
2 1
1 3
>> C^2
ans =
5 5
5 10
C=
2 1
1 3
D=
3 1
5 3
>> C*D
ans =
11 5
18 10
>> %Comando:E(x)=[]
E=
3 13 5 0 8 90 76 54
>> E(6)=[]
E=
3 13 5 0 8 76 54
>> %Comando:B=A´
A=
1 2 3
5 7 -1
2 3 4
1 1 1
>> B=A'
B=
1 5 2 1
2 7 3 1
3 -1 4 1
>> u=[1 2 3]
u=
1 2 3
>> v=[4 5 6]
v=
4 5 6
ans =
32
>> %Coamndo:cross(u,v)
>> u=[1 2 3]
u=
1 2 3
>> v=[4 5 6]
v=
4 5 6
>> cross(u,v)
ans =
-3 6 -3
>> %operación:Calcula el determinante
>> %Comando:det(x)
>> D=[3 1 ;5 3]
D=
3 1
5 3
>> det(D)
ans =
4.0000
>> %Comando:Xi=inv(x)
>> D=[3 1; 5 3]
D=
3 1
5 3
>> Di=inv(D)
Di =
0.7500 -0.2500
-1.2500 0.7500
>> %operación:Ordena los elementos en forma ascendente
>> %Comando:sort(x)
A=
-2 4 7
5 -6 -4
-2 -7 -9
ans =
-2 -7 -9
-2 -6 -4
5 4 7
>> %Comando:-sort(-x)
A=
1 2 3
5 7 -1
2 3 4
1 1 1
ans =
5 7 4
2 3 3
1 2 1
1 1 -1
ans =
1 0 0
0 3 0
0 0 -4
>> %Comando:A(X1,X2)=cte
A=
2 -3
-4 5
6 -7
A=
2.0000 -3.0000
-4.0000 5.0000
0.5000 -7.0000
>> A(2,:)=[1 1]
A=
2.0000 -3.0000
1.0000 1.0000
0.5000 -7.0000
>> %Comando:A(:,2)=[]
A=
1 -1 2
2 0 1
0 1 -3
>> A(:,2)=[]
A=
1 2
2 1
0 -3
>> A=[2 3; 1 4; 7 6]
A=
2 3
1 4
7 6
A=
7 6
1 4
2 3
>> %Comando:max(x)
>> % min(x)
>> % [valor,ubicación]=max(x)
x=
1 2 3 5 3 1 -7
>> max(x)
ans =
>> min(x)
ans =
-7
>> [cual, donde]=max(x)
cual =
donde =
A=
1 2 3
5 7 -1
2 3 4
1 1 1
ans =
5 7 4
cual =
5 7 4
donde =
2 2 3
ans =
A=
1 3 5 7
3 4 9 6
6 8 0 7
>> B=A(:,3)
B=
>> C=A(2,:)
C=
3 4 9 6
>> D=A(2:3,:)
D=
3 4 9 6
6 8 0 7
>> E=A(2:3,2:3)
E=
4 9
8 0
>> %solucion
>> R1=15; R2=18; R3=10; R4=9; R5=5; R6=14; R7=8; R8=13; R9=5; R10=2;
A=
-15 0 2 0 8
0 -43 18 10 0
2 18 -34 9 5
0 10 9 -33 14
8 0 5 14 -35
B=
38
-38
20
24
>> I=A\B
I=
-4.1206
-0.1420
-1.2706
-2.1234
-2.6584
>> y=cos(x);
>> z=sin(2*x);
>> x=0:0.01:2*pi;
>> Y=[cos(x);sin(2*x)];
>> plot(x,Y)
>> xlabel('ejex')
>> ylabel('ejey')
>> grid on
>> t=linspace(0,2*pi,20);
>> hold on
>> pause
>> bar(A,E,'r')
>> xlabel('años')
>> stem(S,E)
>> t=0:.01:2*pi;
>> polar(t,abs(sin(2*t).*cos(2*t)));
>> x=0:0.1:4;
>> y=sin(x.^2).*exp(-x);
>> stem(x,y)
>> figure
>> [x,y]=meshgrid(-1:0.03:1,-1:0.03:1);
>> z=x.^2-y.^2;
>> hold on
>> t=(0:0.1:6*pi);
>> x=sqrt(t).*sin(2*t);
>> plot3(x,y,z,'k','linewidth',1);
>> grid on
>> sphere
>> 0;
>> [x,y,z]=sphere(20);
>> surf(x,y,z);
>> [x,y,z]=sphere(50);
>> props.AmbientStrength=0.1;
>> props.DiffuseStrength=1;
>> props.SpecularColorReflectance=.5;
>> props.SpecularExponent=20;
>> props.SpecularStrength=1;
>> props.FaceColor='texture';
>> props.EdgeColor='none';
>> props.FaceLighting='phong';
>> props.Cdata='topo';
>> view(3)
>> hold on
>> colormap|topomap1|;
>> Excel=xlsread('Analisisimport.xlsx');
>> P=Execel(:,1);
>> G=Excel(:,2);
>> grid on