error checking in matlab
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a code segment where I am error checking input arguments and I am having issues making it work... the structure for the code for the two error checks are the following:
error code should be m>n or n<1 and xi=xj for i!=j
if (m>n)||(n<1)
error('myApp:argChk', 'check for correctness of input')
end
for i = 1:n
for j = i+1:m
if x(i,1)=x(j,1)
error('myApp:argChk', 'check for correctness of input')
end
end
end
0 commentaires
Réponses (1)
Matt Fig
le 20 Nov 2012
Modifié(e) : Matt Fig
le 20 Nov 2012
When asking a question, you need to explain what you post. What is m and n? Are they supposed to be the size of x, like:
[m,n] = size(x)
or what? Are they passed in or calculated in your function?
There is an error on this line:
if x(i,1)=x(j,1)
it should read:
if x(i,1)==x(j,1)
Please be more specific about what you want to do. This statement:
x(ii) must be equal to x(jj) for ii~=jj
doesn't make much sense. Do you mean:
x(ii,jj) must be equal to x(jj,ii) for ii~=jj
What about non-square matrices?
0 commentaires
Voir également
Catégories
En savoir plus sur Elementary Math 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!