How do I define symblic variable in a subfunction in matlab? Getting: “Attempt to add ”bar“ to a static workspace.”
Show older comments
I'm trying to define a symbolic variable in a sub function foo (see below)
function [ ] = test2( )
();
function [] = foo ()
syms bar;
end
end
I get the following error and am not sure how I can resolve this:
EDU>> test2 Error using assignin Attempt to add "bar" to a static workspace. See MATLAB Programming, Restrictions on Assigning to Variables for details.
Error in syms (line 66) assignin('caller',x,sym(x));
Error in test2/foo (line 6) syms bar;
Error in test2 (line 3) foo();
Would appreciate any help to sort out the above
Answers (1)
Walter Roberson
on 28 Mar 2013
bar = sym('bar');
2 Comments
Bogdan -Ervin
on 7 Apr 2024
Do you know the syntax which works for Matlab R2023b?
Walter Roberson
on 7 Apr 2024
bar = sym('bar');
Categories
Find more on Software Development 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!