How to create symbol function matrix in matlab?

5 vues (au cours des 30 derniers jours)
Chuangchuang Sun
Chuangchuang Sun le 8 Déc 2014
Commenté : Andrew Newell le 8 Déc 2014
I need to solve a linear differential equations, such as diff(Y) = AY, Y(0) = Y0. Y \in R^n; So I need to generate a column of symbol function. I used the following code
clc;clear;
n = 7;
syms t V;
A = sym('A', [n 1]);
U = symfun(A,[t]);
However, as the result shows, the size of U is 1 by 1. I don't know what is wrong and how I can make it work.
I will appreciate your help a lot. Best,

Réponse acceptée

Star Strider
Star Strider le 8 Déc 2014
The solution to your differential equation (assuming a constant ‘A’) is:
Y = expm(A*t)
You will likely have significant problems with it in the Symbolic Math Toolbox. I would deal with it only numerically.
  1 commentaire
Andrew Newell
Andrew Newell le 8 Déc 2014
Not quite - the correct answer is
Y = expm(A*t)*Y0

Connectez-vous pour commenter.

Plus de réponses (1)

Andrew Newell
Andrew Newell le 8 Déc 2014
To get an n x n matrix, use
A = sym('A',n);
  1 commentaire
Chuangchuang Sun
Chuangchuang Sun le 8 Déc 2014
I change the way to generate A but the resulting U is still shown to be 1 by 1. It seems it doesn't make a difference. Thanks!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by