Solving two equations simultaneously then plotting
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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!
0 Commenti
Risposte (1)
Star Strider
il 23 Mar 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
Here, both variables are changed inside the nested loops, and the result saved to a matrix.
.
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!