Converting matrix multiplication into element-wise multiplication
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
adrien ameye
am 7 Apr. 2021
Kommentiert: Star Strider
am 7 Apr. 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 Kommentare
Akzeptierte Antwort
Star Strider
am 7 Apr. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!