System solving using rref
6 次查看(过去 30 天)
显示 更早的评论
Hello,
So I am trying to write a system solving script using rref. Matrix and vector, A and B, are given already. What is needed is solving the 3 equation, also given, and produce an output file that looks like screenshot 1, but instead i get an output of screenshot 2. And I apologize for not including the code into the body, but i have no clue how to do it properly.
Thanks
2 个评论
回答(2 个)
Walter Roberson
2018-9-6
fprintf('Equation 1 is: %s\nEquation 2 is: %s\nEquation 3 is: %s\n', Eq1, Eq2, Eq3);
fprintf('The solutions are as follows:\n');
Now calculate the solutions and store them in variables X, Y, and Z, then:
fprintf('x = %.4f\ny = %.4f\nz = %.4n\n', X, Y, Z)
I recommend that you do not store the solutions in variables x, y, and z, as that gets confusing against the use of x, y, and z as symbolic variables.
2 个评论
Walter Roberson
2018-9-6
We have no information about relationship A and B have to the rest of the question.
My guess is you want something like
for row = 1 : size(A,1)
fprintf('Equation %d is: %5fx + %5fy + %5fz = %5f\n', A(row,:), B(row));
end
and that you want to use rref() to solve the system
A*[x;y;z] = B
It is easy to do, taking only a few characters, but figuring out how is an important part of the homework.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Equation Solving 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!