error checking in matlab
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Matt Fig
am 20 Nov. 2012
Bearbeitet: Matt Fig
am 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 Kommentare
Siehe auch
Kategorien
Mehr zu Elementary Math finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!