Alternative way of defining a variable

17 views (last 30 days)
Saurabh Madankar
Saurabh Madankar on 19 Oct 2021
Answered: Walter Roberson on 19 Oct 2021
Is there any way I can define a variable without assigning it any value and not using syms?
  1 Comment
KSSV on 19 Oct 2021
In what contest? What is the requirement?

Sign in to comment.

Answers (2)

KSSV on 19 Oct 2021
a = zeros([],1) ;
b =[] ;
But it depends. What is the requirement?
Walter Roberson
Walter Roberson on 19 Oct 2021
ans = 
Does not directly use sym() or syms() . It uses sym() internally though.
Is the point that you need to be able to use piecewise() but for some reason you cannot use symbolic variables? Note that piecewise() is part of the symbolic toolbox, so if you have a restriction against using the symbolic toolbox then you cannot use piecewise()

Sign in to comment.

Walter Roberson
Walter Roberson on 19 Oct 2021
Problem based optimization permits you to use optimvar() to define variables to be optimized over, without giving the variables specific values.
This probably satisfies your question as originally asked.
Unfortunately, piecewise() cannot be used with problem-based optimization.

Community Treasure Hunt

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

Start Hunting!