"Generate a 2 x 4 matrix variable mat. Verify that the number of elements is equal to the product of the number of rows and columns."
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
My professor gave this questiion from the book, but I don't understand what it wants me to do exactly. what does "Verify that the number of elements is equal to the product of the number of rows and columns." mean??
2 comentarios
Bruno Luong
el 5 de Sept. de 2019
Editada: Bruno Luong
el 5 de Sept. de 2019
A = rand(2,4);
neA = numel(A)
nr = size(A,1)
nc = size(A,2)
if neA == nr*nc
fprintf('youhooo\n');
else
% fprintf('Mathworks makes a buggy code!\n');
fprintf('math is an illusion\n');
end
Matt J
el 6 de Sept. de 2019
My professor gave this questiion from the book, but I don't understand what it wants me to do exactly.
Then why ask us? Why not ask your professor? Your professor understands better than anybody what he/she wants.
Respuestas (1)
Star Strider
el 5 de Sept. de 2019
There is a function that will do exactly this. If you don’t want to use that function, reshape your matrix to a vector, then determine the number of elements in the vector.
0 comentarios
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!