Searching for minimum x root for known y

조회 수: 2 (최근 30일)
Panos Katsa
Panos Katsa 2020년 2월 20일
댓글: Panos Katsa 2020년 2월 20일
Hello. I am beginner with matlab and I'm getting confused so I would like some help.
I have the equation y = -0,1042x^5 + 1,9167x^4 - 13,062x^3 + 39,333x^2 - 45,083x + 21 and I have also inserted a matrix of 8760 y values.
I want to build a table that displays the minimum root of x every time for given y values.
Any help?
  댓글 수: 3
Panos Katsa
Panos Katsa 2020년 2월 20일
i dont know exaclty how to make equations between this function for instance and each and every column of the matrix
Alex Mcaulley
Alex Mcaulley 2020년 2월 20일
편집: Alex Mcaulley 2020년 2월 20일
For each value in y you can obtain the roots using roots function and then take the minimum value using min
Hints:
  • for loop might be useful
  • read the documentation of roots

댓글을 달려면 로그인하십시오.

채택된 답변

the cyclist
the cyclist 2020년 2월 20일
This code finds the minimum root, for y == 43.
y = 43;
p = [-0.1042 1.9167 13.062 39.333 45.083 21-y];
min(roots(p))
You'll need to run a loop over your values of y.
  댓글 수: 5
the cyclist
the cyclist 2020년 2월 20일
편집: the cyclist 2020년 2월 20일
Here is one way to convert from table to numeric. I also documented what the prior code was doing.
% Create a variable y that is a table (where the variable *inside* the table is also named
% "y"). You should use your real data here instead
y = table([22; 44],'VariableNames',{'y'});
% Convert it to numeric
y_numeric = table2array(y);
% Get the number of values
y_count = numel(y_numeric);
% Preallocate the array for the minimum values
minValues = zeros(y_count,1);
% Loop over each value of y, and store the minimum root
for iy = 1:y_count
p = [-0.1042 1.9167 13.062 39.333 45.083 21-y_numeric(iy)];
minValues(iy) = min(roots(p));
end
Panos Katsa
Panos Katsa 2020년 2월 20일
thanks a lot

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by