Borrar filtros
Borrar filtros

Solving two equations simultaneously then plotting

2 visualizaciones (últimos 30 días)
AJ99
AJ99 el 23 de Mzo. de 2022
Respondida: Star Strider el 23 de Mzo. de 2022
Hi, I have only ever used matlab at a beginner level and havent touched it in a while. What I am trying to do is to solve an equation for a specific variable. Once this is done, another variable from the equation needs to be adjusted, and then the equation needs to be solved again. I want to record these results in an array so that they can both be plotted against time so that I can see how the variables evolve. Simultaneously, I need to use these calculated values as part of a second seperate equation to find another two variables, both of which I would also like to plot. I am trying to write some pseudocode so that I can get my head around this. It is likely not a very complicated thing to code, however I am strugling and would appreciate any help and advice. Thanks in advance!

Respuestas (1)

Star Strider
Star Strider el 23 de Mzo. de 2022
For the first part, see if somoething like this would work —
n = 1:10;
m = 1:5;
[N,M] = ndgrid(n,m);
f = @(x,n,m) m.*x.^2 - n;
for k1 = 1:numel(n)
for k2 = 1:numel(m)
rp(k1,k2) = fzero(@(x)f(x,n(k1),m(k2)), rand); % Calculate Positive Root
end
end
rp
rp = 10×5
1.0000 0.7071 0.5774 0.5000 0.4472 1.4142 1.0000 0.8165 0.7071 0.6325 1.7321 1.2247 1.0000 0.8660 0.7746 -2.0000 -1.4142 1.1547 1.0000 0.8944 2.2361 1.5811 1.2910 1.1180 1.0000 2.4495 1.7321 1.4142 1.2247 1.0954 -2.6458 1.8708 1.5275 1.3229 1.1832 -2.8284 2.0000 1.6330 1.4142 1.2649 -3.0000 2.1213 1.7321 1.5000 1.3416 3.1623 2.2361 1.8257 1.5811 1.4142
Here, both variables are changed inside the nested loops, and the result saved to a matrix.
.

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by