필터 지우기
필터 지우기

graphing with a matrix using matlab

조회 수: 12 (최근 30일)
Khang Nguyen
Khang Nguyen 2020년 11월 22일
편집: Mohith Kulkarni 2020년 11월 25일
If I have a reduce normal form Matrix on matlab for example A = [ 1 0 0 3 ; 0 1 0 6 ; 0 0 1 5]
I want to graph it in an equation y = a + bx +cx^2 where a = 3 , b = 6 and c = 5(3,6,5 is the last value in the matrix above). How should i do this. I am trying to solve the lease square problem in linear algebra.
Can you please give me an advice of how to write a code to do this if the matrix increasing.
Thank you

답변 (1개)

Mohith Kulkarni
Mohith Kulkarni 2020년 11월 25일
편집: Mohith Kulkarni 2020년 11월 25일
To plot the equation, refer to the code below.
A = [1 0 0 3; 0 1 0 6; 0 0 1 5]
B = A(:,end) %last column for a,b,c
x = linspace(1,10,10); %initializing x values
y = zeros(10,1)'; %initializing y values
deg = size(A,2)-2;
for idx = 0:deg
y = y+ B(idx+1)*(x.^idx);
end
plot(y,x)
For solving system of linear equations using least squares method, refer to lsqr.
You can also check polyfit for polynomial curve fitting.

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by