error checking in matlab
5 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Matt Fig
on 20 Nov 2012
Edited: Matt Fig
on 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 Comments
See Also
Categories
Find more on Elementary Math in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!