error checking in matlab

5 次查看(过去 30 天)
Sam
Sam 2012-11-20
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

回答(1 个)

Matt Fig
Matt Fig 2012-11-20
编辑:Matt Fig 2012-11-20
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?

类别

Help CenterFile Exchange 中查找有关 Elementary Math 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by