Write a script to create a matrix B equal to A, but with its last column equal set to 0.
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
NSIKAN
el 7 de Abr. de 2023
Editada: John D'Errico
el 7 de Abr. de 2023
Can someone help with a hint of this question using MATLAB?
Write a script to create a matrix B equal to A, but with its last column equal set to 0.
0 comentarios
Respuesta aceptada
chicken vector
el 7 de Abr. de 2023
Editada: chicken vector
el 7 de Abr. de 2023
I suppose you want to limit your case to bi-dimensional arrays.
You can create a function which works for every matrix
function A = createCopyWithNullLastColumn(A)
% Change values of last column :
A(:,end) = 0;
end
Or go with the script:
% Create random matrix <A>:
A = rand(randi([1,10]), randi([1,10]));
% Create a copy <B> of <A>:
B = A;
% Set last column of <B> equal to <0>:
B(:,end) = 0;
1 comentario
John D'Errico
el 7 de Abr. de 2023
Editada: John D'Errico
el 7 de Abr. de 2023
Please don't do obvious homework assignments for students. This never helps the student, who learns nothing more than they can find someone willing to do their work for them, if they only plead sadly enough.
It does not help the site, since it convinces that student to continue to post their homework assignments, with no effort made.
Worse, it actively hurts the site, because then it convinces other students they have the right to post their homework assignments too. You then help to turn answers into a site where nothing is seen except for students angrily demanding that we do their homework for them, and do it quickly.
If you feel compelled to help, then offer some guidance. Push them in the right directino. Here, you might have suggested they create a smaller random matrix, and then append zeros, or something like that, but NOT write the code for them.
Más respuestas (0)
Ver también
Categorías
Más información sobre Creating and Concatenating 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!