How do you use values from an array as serial numbers to extract values from a different array?

조회 수: 1 (최근 30일)
If I am using an array to record values such as [0:10:100], then how can I create a column vector containing values extracted from a table(with two columns, one of which is the independent variable and the other is the dependent variable) with the intervals 0, 10, 20,...,100?

답변 (1개)

Star Strider
Star Strider 2020년 10월 17일
It is not possible to reference ‘row 0’ since MATLAB subscripts begin at 1.
I am not certain what you want, so see if this short example works for you:
T1 = array2table(randi(100, 35, 2)); % Create Random Table
T2ext = T1([1 10:10:30],:); % Extract Rows
.
  댓글 수: 4
Vedeesh Bali
Vedeesh Bali 2020년 10월 18일
I think I can explain now.
If one of the values 'x' present in vfit also exists in my imported table, I want to extract the 'y=f(x)' values corresponding to the table.
Eg: if I have this table
x1 y1
x2 y2
. .
. .
. .
xn yn
And x2 and xn belong to vfit, how can I create an array containing y2 and yn?
Star Strider
Star Strider 2020년 10월 18일
My final suggestion is to use interp1:
yi = interp1(x, y, vfit)
Out = [vfit, yi]
That will likely produce the result you want, even though I still have no idea what that is. Note that for this to work, both ‘x’ and ‘vfit’ must be monmotonically either increasing or decreasing, and both must go in the same direction.

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

카테고리

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

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by