MATLAB Answers

0

Too many output arguments with if condition, and assume

Asked by Ali Tawfik on 25 Aug 2019 at 14:35
Latest activity Commented on by Rik
on 25 Aug 2019 at 21:14
Hi
I got that error while I am using if condition with assume, so please any help.
clear all;
close all;
clc;
syms x y;
yin=[(solve(-1500<.2500*x+.7500*y+20.78,y)),(solve(.2500*x+.7500*y+20.78<1500,y))]
% %@x=100
yin2=[-100/3 - 152003/75, 147847/75 - 100/3]
if assume(-2060<y & y<1938)
display('ok')
else
display('nothing')
end

  5 Comments

Rik
on 25 Aug 2019 at 19:08
The y variable is a sym, so the test you're trying to do doesn't make sense.
Normally this should work:
y=5;
%use && for scalars
%don't enter non-scalars to if, it will probably not do what you mean
if -10<y && y<10
disp('foo')
else
disp('bar')
end
If you want a crash course in Matlab, you could try Onramp.
Thanks, I know what you wrote, but no way to have kinda of interval inequlaities with syms ?
Thanks,
Rik
on 25 Aug 2019 at 21:14
There probably is, but that is not what your code is doing. And I hardly ever work with syms (and I don't have the toolbox), so you'll have to google that yourself.

Sign in to comment.

0 Answers