
How to solve simultaneous equations?
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
How to solve simultaionsequations such as this,
f1(x1,x2) = x1^2 + x1*x2 - 10;
f2(x1,x2) = x2 + 3*x1*x2^2 - 57;
with and without using symbolic functions for f1 and f2. Please do explain the process.
2 Kommentare
Image Analyst
am 13 Okt. 2021
Do you mean you want to do it numerically? Like with some specific, discrete values for x? What range of x do you want to cover?
clc; % Clear the command window.
fprintf('Beginning to run %s.m ...\n', mfilename);
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
numPoints = 50;
X1 = linspace(-5, 5, numPoints);
X2 = linspace(-2.5, 2.5, numPoints/2);
[x1, x2] = meshgrid(X1, X2);
f1 = x1.^2 + x1.*x2 - 10;
f2 = x2 + 3*x1.*x2.^2 - 57;
subplot(2, 2, 1);
imshow(f1, [], 'XData', [min(x1), max(x1)], 'YData', [min(x2), max(x2)])
axis('on', 'xy')
impixelinfo
title('f1', 'FontSize', fontSize);
xlabel('x1', 'FontSize', fontSize);
ylabel('x2', 'FontSize', fontSize);
subplot(2, 2, 2);
imshow(f2, [], 'XData', [min(x1), max(x1)], 'YData', [min(x2), max(x2)])
axis('on', 'xy')
impixelinfo
title('f2', 'FontSize', fontSize);
xlabel('x1', 'FontSize', fontSize);
ylabel('x2', 'FontSize', fontSize);
diffImage = abs(f1 - f2);
subplot(2, 2, 3);
imshow(diffImage, [], 'XData', [min(x1), max(x1)], 'YData', [min(x2), max(x2)])
axis('on', 'xy')
impixelinfo
title('abs(f2 - f1)', 'FontSize', fontSize);
xlabel('x1', 'FontSize', fontSize);
ylabel('x2', 'FontSize', fontSize);
subplot(2, 2, 4);
surf(x1, x2, diffImage, 'EdgeColor','none')
title('f2 - f1', 'FontSize', fontSize);
xlabel('x1', 'FontSize', fontSize);
ylabel('x2', 'FontSize', fontSize);
g = gcf;
g.WindowState = 'maximized'
minValue = min(diffImage(:))
[rows, columns] = find(diffImage == minValue)
x1AtMin = X1(columns)
x2AtMin = X2(rows)
subplot(2, 2, 3);
hold on;
plot(x1AtMin, x2AtMin, 'r*', 'LineWidth', 2, 'MarkerSize', 30)
subplot(2, 2, 4);
hold on;
plot3(x1AtMin, x2AtMin, minValue, 'r*', 'LineWidth', 2, 'MarkerSize', 30)

Antworten (1)
Bjorn Gustavsson
am 14 Okt. 2021
Using symbolic tools you have solve - look at the help and documentation for that function for examlpes. Your problem should reduce to a cubic polynomial so should be possible to check "semi-manually".
0 Kommentare
Siehe auch
Kategorien
Mehr zu Linear Algebra finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!