Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
I am trying to write a matlab function that that takes a matrix as input and test if that matrix is a square(using a sub-function) and if it is a square it must test if it meets a certain condition. Here is my code
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
function [a,b] = matr(A)
[a,b]=size(A)
d=diag(A)
S=sum(d==0)
Results = tests(a,b)
if S>0.5*length(d)
RT1=1
disp('The matrix is a Romanov type 1.\n')
else
RT1=0
disp('The matrix is not Ramanov type 1.\n')
end
end
function test = tests(a,b)
if a==b
d=diag(A);
S = sum(d==0)
disp('The matrix is a square matrix.\n')
end
end
1 commentaire
Réponses (0)
Cette question est clôturée.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!