How can I change values in my matrix according to conditions.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hannah Pickering
el 7 de Feb. de 2017
Respondida: Chad Greene
el 7 de Feb. de 2017
I have a zeros(size,size) matrix that i want the values to change depending on my conditions. I have two conditions:
Support = FixedFixed or Support = PinnedPinned
When Support = FixedFixed my matrix coordinates should be
a(1,1) = 7;
a(1,2) = -4;
a(1,3) = 1;
a(size,size-2)=1;
a(size,size-1)=-4;
a(size,size)=7;
and when Support = PinnedPinned my matrix should be
a(1,1) = 5;
a(1,2) = -4;
a(1,3) = 1;
a(size,size-2)=1;
a(size,size-1)=-4;
a(size,size)=5;
can anyone help me code this?
0 comentarios
Respuesta aceptada
Chad Greene
el 7 de Feb. de 2017
switch SupportType
case 'PinnedPinned'
a(1,1) = 5;
a(1,2) = -4;
a(1,3) = 1;
a(size,size-2)=1;
a(size,size-1)=-4;
a(size,size)=5;
case 'FixedFixed'
a(1,1) = 7;
a(1,2) = -4;
a(1,3) = 1;
a(size,size-2)=1;
a(size,size-1)=-4;
a(size,size)=7;
end
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Operating on Diagonal Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!