Error: Unable to convert 'ureal' to 'sym'

5 ビュー (過去 30 日間)
Jakob Poulsen
Jakob Poulsen 2021 年 3 月 16 日
コメント済み: Jakob Poulsen 2021 年 3 月 19 日
Hi
I am working with the Robust Control Toolbox and want to pass values of type 'ureal' to a symbolic matrix through a function.
It works fine if I write the matrix in my function manually, e.g.
x = ureal('x',10,"Percentage",20);
my_fun(x)
function A = my_fun(x)
A = [x 1; 1 x]
end
However, I want to load my matrix from a .mat file instead of instead writing it manully, e.g.
syms x
A = [x 1; 1 x];
save('matrix.mat','A')
x = ureal('x',10,"Percentage",20);
my_fun(x)
function A = my_fun(x)
loaded_matrix = load('matrix.mat')
A_symbolic = loaded_matrix.A
A = subs(A_symbolic)
end
This does not work and I get the error "Error: Unable to convert 'ureal' to 'sym".
Is there a workaround for this problem? How do I pass my ureal-type to my function such that I get a numeric matrix?
Hope someone can help me!

回答 (1 件)

Pranav Verma
Pranav Verma 2021 年 3 月 19 日
Hi Jakob,
Try replacing the last line of the my_fun,
A = subs(A_symbolic)
to,
A = sym(A_symbolic)
Hope this helps.
Thanks
  1 件のコメント
Jakob Poulsen
Jakob Poulsen 2021 年 3 月 19 日
Hi Pranav,
Thank you for your aswer.
Maybe I formulated my question wrong. I want my output from my_fun(x) to be a numeric umat matrix.

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

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by