"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."
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Bruno Luong
le 5 Sep 2019
Modifié(e) : Bruno Luong
le 5 Sep 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
le 6 Sep 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.
Réponses (1)
Star Strider
le 5 Sep 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 commentaires
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!