matlab
@jim_thompson5910
Need suggestions. I was thinking about using a while loop and asking the user to input x, y, z values.
so basically do guess and check?
Yes, but I was just reading the lab and I need to load the CSV files.
guess and check is one way to do it, but it's very tedious and you may never actually get the answer no matter how hard you try to guess it
using rref is a much better way
well, I was going to use rref, but I wanted to ask the user to input values in for equation 1, equation 2, and equation 3.
This is my idea....
the values are drawn from the csv files
oh okay... So the values in the CSV are my inputs?
yes for the coefficients and right hand side
Okay thanks. Let me think about that more and I will get back to you later.
This is the assignment.
My work, please check. clear, clc, close all; % clears all windows % loads CSV files into matlab matrixA = csvread('A.csv'); matrixB = csvread('B.csv'); % combining matrices A and B matrixSystem = horzcat(matrixA, matrixB); % solves the system of equations S = rref(matrixSystem); % extracting last column in S matrix solveX = S(1, 4); solveY = S(2, 4); solveZ = S(3, 4); % output displayed fprintf('Equation 1: 1x + -2y + 3z = 7 \n'); fprintf('Equation 2: 2x + 1y + 1z = 4 \n'); fprintf('Equation 3: -3x + 2y + -2z = 1 \n\n'); fprintf('The solutions are as follows \n\n'); fprintf('x = %0.4f \n', solveX); fprintf('y = %0.4f \n', solveY); fprintf('z = %0.4f \n\n', solveZ);
check
Join our real-time social learning platform and learn together with your friends!