How can use "is not equal to" command in matlab? and how terminate or cancel if else??
3 views (last 30 days)
Show older comments
if i want to restrict variable
length(a) "is not equal to" length(b);
length(c) "is not equal to" length(a);
then terminate
end
0 Comments
Accepted Answer
James Tursa
on 4 Nov 2015
E.g.,
if( length(a) ~= length(b) || length(c) ~= length(a) )
% terminate
end
For the terminate statement, you need to be more clear. If you are terminating a loop of some sort, then
break;
If you are terminating a function with an error return, then
error('Lengths are not equal');
If termination means something else, then you need to tell us.
1 Comment
James Tursa
on 4 Nov 2015
Then use the error function as shown above. E.g.,
if( length(a) ~= length(b) || length(c) ~= length(a) )
error('Error- dimensions of array is not equal');
end
If the error is not handled by a try-catch, then this will terminate the program with an error statement.
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!