I want to change the symbolic variables in my matrix to numbers

44 ビュー (過去 30 日間)
Charles
Charles 2024 年 4 月 17 日 11:04
コメント済み: Star Strider 2024 年 4 月 17 日 12:35
To make it simpler to explain, I just want to plot the results of this final matrix. But it gives me zero as the answer because it is in a symbolic format. Is there a way to change it to the actual value ?
clear all ; close all; close ; clear
syms s
Expr = (sin(s));
F1 = int(Expr)
F1 = 
syms n
expr2 = 1/n ;
F2 = int(expr2)
F2 = 
total = F2 == F1
total = 
final = isolate(total,n)
final = 
want2plot = subs(final,s,0:0.1:5)
want2plot = 

採用された回答

Star Strider
Star Strider 2024 年 4 月 17 日 11:13
編集済み: Star Strider 2024 年 4 月 17 日 12:33
Use the fplot function —
clear all ; close all; close ; clear
syms s
Expr = (sin(s));
F1 = int(Expr)
F1 = 
syms n
expr2 = 1/n ;
F2 = int(expr2)
F2 = 
total = F2 == F1
total = 
final = isolate(total,n)
final = 
want2plot = subs(final,s,0:0.1:5)
want2plot = 
figure
fplot(rhs(final), [0 5])
grid
xlabel('s')
ylabel('n')
title('‘fplot’')
Alternatively —
nfcn = matlabFunction(rhs(final))
nfcn = function_handle with value:
@(s)exp(-cos(s))
figure
plot((0:0.1:5), nfcn(0:0.1:5))
grid
xlabel('s')
ylabel('n')
title('‘matlabFunction’')
figure
plot(0:0.1:5, double(rhs(want2plot)))
grid
xlabel('s')
ylabel('n')
title('‘want2plot’')
EDIT — Added the ‘Alternatively —’ section.
EDIT — (16 Apr 2024 at 12:33)
Added independent variable to ‘want2plot’ and added titles.
.
  2 件のコメント
Charles
Charles 2024 年 4 月 17 日 11:16
Thank you very much!! That makes sense, i saw somewhere that you could use the rhs and lhs for stuff but didn't think of using it like this to get the answer.
Star Strider
Star Strider 2024 年 4 月 17 日 12:35
As always, my pleasure!
(I added some asethetic tweaks to my original post. Code unchanged.)

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by