solving similtanous equations in loop
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
given the two vectors
x = [1,2,3,4,5,6,7]
y = [1,2,3,4,5,6,7]
how can i solve the system of equations (this could be any equation)
-3*w*sin(x)+ 5*q*sin(y)-10 = 0
3*w*cos(x) - 5*q*cos(y) = 0
I need to find the variables w and q in matrix form.
0 Commenti
Risposte (1)
Star Strider
il 16 Ott 2019
One approach:
x = [1,2,3,4,5,6,7];
y = [1,2,3,4,5,6,7];
[X,Y] = meshgrid(x,y);
xv = X(:);
yv = Y(:);
% -3*w*sin(x)+ 5*q*sin(y)-10 = 0
% 3*w*cos(x) - 5*q*cos(y) = 0
FM = @(w,q,x,y) [-3*w*sin(x) 5*q*sin(y)-10; 3*w*cos(x) -5*q*cos(y)];
for k = 1:numel(xv)
B(:,k) = fsolve(@(b) FM(b(1),b(2),xv(k),yv(k)), [100;100]);
end
Here ‘B(1,:)’ is ‘w’, and ‘B(2,:)’ is ‘q’. They are due to the matching ‘xv(k)’ ‘yv(k)’ combineations for each ‘k’.
Experiment to get the result you want.
0 Commenti
Vedere anche
Categorie
Scopri di più su Mathematics and Optimization in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!