vpasolve in for loop

2 views (last 30 days)
maedeh Gh
maedeh Gh on 19 Feb 2019
Commented: Etsuo Maeda on 5 Mar 2019
I Run this code and it works correctly, but I wanna stop the for loop when it gets Empty sym: 0-by-1
for p=0:10
ub= vpasolve(function==0,x,[1000*p,1000*(p+1)])

Answers (1)

Etsuo Maeda
Etsuo Maeda on 5 Mar 2019
"vpasolve" returns numerical values. Its output "ub" cannot be a sym variable. If you use "solve", you can use "isempty" and "break" for your pourpose.
syms x
for k = 1:2
out = solve(x^k + 1 == 0, x)
if isempty(out) == 1
disp('in loop')
Etsuo Maeda
Etsuo Maeda on 5 Mar 2019
UUUps, thank you very much for your kind correction :-)

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by