Alternative way of defining a variable

조회 수: 3 (최근 30일)
Saurabh Madankar
Saurabh Madankar 2021년 10월 19일
답변: Walter Roberson 2021년 10월 19일
Hello,
Is there any way I can define a variable without assigning it any value and not using syms?
  댓글 수: 1
KSSV
KSSV 2021년 10월 19일
In what contest? What is the requirement?

댓글을 달려면 로그인하십시오.

답변 (2개)

KSSV
KSSV 2021년 10월 19일
a = zeros([],1) ;
b =[] ;
But it depends. What is the requirement?
  댓글 수: 3
KSSV
KSSV 2021년 10월 19일
How about anonymous fnctions ?
Walter Roberson
Walter Roberson 2021년 10월 19일
str2sym('t')
ans = 
t
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()

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2021년 10월 19일
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.

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by