Converting matrix multiplication into element-wise multiplication
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
adrien ameye
le 7 Avr 2021
Commenté : Star Strider
le 7 Avr 2021
Hi,
I'm using symbolic toolbox to solve non-linear differential equations.
It return an approximate solution with this formalism :
((Theta*w^2 - Theta*w0^2)^2 + (Theta^2*w^2*w0^2)/Q^2)^(1/2)
(Theta and w are two variables, and w0 and Q are two constants)
The aim is to replace Theta and w by grids :
Theta = linspace(0, 10, 1000);
w = linspace(0.1, 10, 501);
[w_grid, Theta_grid] = meshgrid(w, Theta);
((Theta_grid.*w_grid.^2 - Theta_grid.*w0.^2).^2 + (Theta_grid.^2.*w_grid.^2*w0^2)./Q^2).^(1/2)
It work perfectly, but i have to replace all the operators " * ", " / " and " ^ " by the operators " .* ", " ./ " and " .^ ", and then to change all the variables by the grids.
Is there a way to make this change automatically? For the moment, I have to do it manually.
0 commentaires
Réponse acceptée
Star Strider
le 7 Avr 2021
I am not certain what you are doing, however it appears that using matlabFunction to convert the symbolic code to a form that can be used in numeric computations could do what you want.
2 commentaires
Plus de réponses (0)
Voir également
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!