How to convert symbolic array into a vector

19 ビュー (過去 30 日間)
SALMAN KHAN
SALMAN KHAN 2021 年 9 月 6 日
コメント済み: Star Strider 2021 年 9 月 6 日
Using symbolic matlab, when I calculate values of a function f(x) it given me a symbolic array, but I want this in form of a vector so that I can plot L vs x?
x = 0:0.01:1 L = f(2) + df(2)*(x-2)

採用された回答

Star Strider
Star Strider 2021 年 9 月 6 日
I am not certain what you want to do, or the specific problem.
It might be easiest to create the ‘L’ assignment as a function using matlabFunction, then evaluate it numerically —
syms f(x) df(x) x
f(x) = x^2;
df = diff(f);
L = f(2) + df(2)*(x-2)
L = 
Lfcn = matlabFunction(L)
Lfcn = function_handle with value:
@(x)x.*4.0-4.0
x = linspace(0, 5, 10);
Lval = Lfcn(x)
Lval = 1×10
-4.0000 -1.7778 0.4444 2.6667 4.8889 7.1111 9.3333 11.5556 13.7778 16.0000
figure
plot(x, Lval)
grid
Make appropriate changes to get the result you want.
.
  2 件のコメント
SALMAN KHAN
SALMAN KHAN 2021 年 9 月 6 日
My pleasure, this is what exactly I wanted.
Star Strider
Star Strider 2021 年 9 月 6 日
Thank you!
.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by