Deleting Row and Column
Mostrar comentarios más antiguos
I am doing a project with matrices. I want to change the size of the matrix by deleting the last 2 rows and the last 2 column. I want to go from 0.01 to 0.15 in steps of 0.01. When I display Q1 I am able to delete the last 2 columns but the the last 2 rows and then when I try to delete the rows (disp Q2) it deleted the rows but not the columns. I want BOTH the last two ROW AND last two COLUMN to be deleted from the Matrix P. Any help is appreciated!!!!
P = [0.1 0.75 0 0 0.15 0; 0 0.1 0.8 0 0.10 0; 0 0 0.15 0.75 0.1 0; 0 0 0 0.1 0.1 0.8; 0 0 0 0 1 0; 0 0 0 0 0 1];
disp(P)
for v = 0.01:0.01:0.15
P(1,1) = v + P(1,1);
%disp(P)
Q1 = ([:,1 2 3 4]);
disp(Q1)
Q2 = P([1 2 3 4],:);
%Q2 = P(:, [5 6]);
disp(P)
end
Respuestas (2)
KSSV
el 24 de Abr. de 2020
If A is your matrix, you can remove last two rows and columns using:
[m,n] = size(A) ;
A(m-1:m,:) = [] ; % removes last two rows
A(:,n-1:n) = [] ; % removes last two columns
2 comentarios
Imani DaSilva
el 24 de Abr. de 2020
KSSV
el 24 de Abr. de 2020
Show us the code which you have tried.
James Tursa
el 24 de Abr. de 2020
Q = P(1:end-2,1:end-2);
3 comentarios
Imani DaSilva
el 24 de Abr. de 2020
Imani DaSilva
el 24 de Abr. de 2020
Imani DaSilva
el 24 de Abr. de 2020
Categorías
Más información sobre Circuit Envelope Simulation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!