Converting matrix multiplication into element-wise multiplication

9 views (last 30 days)
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.

Accepted Answer

Star Strider
Star Strider on 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.

More Answers (0)

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!