Converting matrix multiplication into element-wise multiplication

8 次查看(过去 30 天)
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.

采纳的回答

Star Strider
Star Strider 2021-4-7
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by