how i can solve Error using sym/subsindex (line 1558) Indexing input must be numeric, logical or ':'. Error in sym>privformat (line 2357) x = subsindex(x)+1; Error in sym/subsref (line 1578) [inds{k},refs{k}] = privformat(inds{k});

3 ビュー (過去 30 日間)
syms y x fn
fn=cos(x)
b=y+2*y^2
y=fn(b)

採用された回答

Walter Roberson
Walter Roberson 2018 年 5 月 12 日
Your fn is a scalar symbolic variable. The only valid indices you can use for it are 1 or true or false. Your fn is not a function. To define a function you would have needed
fn(x) = cos(x)
With sufficiently old MATLAB releases you would have needed
fn = symfun(cos(x), x)
  2 件のコメント
sadeem alqarni
sadeem alqarni 2018 年 5 月 13 日
thanks , how i can substitution y=fn(b)
Walter Roberson
Walter Roberson 2018 年 5 月 13 日
syms y x fn
fn(x) = cos(x);
b = y + 2*y^2;
z = fn(b);

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by