필터 지우기
필터 지우기

Array of x and y values. Find value of y when x=0, how?

조회 수: 6 (최근 30일)
Elin Berntsson
Elin Berntsson 2017년 11월 27일
댓글: KL 2017년 11월 28일
Hello. I have an assignment in school, where we got an array with x and y values to plot.
Time=[0.5:0.5:5];
A=[1.2 0.73 0.45 0.27 0.16 0.11 0.06 0.035 0.022 0.013];
plot(Time,A) gives me a graph but I need the value of A when Time=0;
I don't have a function or equation, only these values. So when Time=0, what is the value of A?
I'm thinking that some kind of y-intercept thing can be the solution?

답변 (2개)

KL
KL 2017년 11월 27일
You might want to use interp1,
Hint: For your case, 0 lies outside the range you've got, so you might want to extrapolate.
  댓글 수: 5
Elin Berntsson
Elin Berntsson 2017년 11월 27일
Yeah so I've been trying a few times now but i don't think I'm using the interp1 function right.
this is my code so far:
Time=[0.5:0.5:5];
A=[1.2 0.73 0.45 0.27 0.16 0.11 0.06 0.035 0.022 0.013];
plot(Time,A)
A0 = interp1(A,0,linear,extrap)
it's not working and I still kinda don't understand the description that mathworks has for it.. Thankful for your help!
KL
KL 2017년 11월 28일
I agree with the cyclist. In your question you say ...I don't have a function or equation, only these values... and looks like you do have one.

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


the cyclist
the cyclist 2017년 11월 27일
Strictly speaking, it is not possible to know what the value of A is at Time=0, given only this information. An infinite number of functions could fit these data, and give different values at Time=0. Or maybe Time=0 is an asymptote, and the fit line never crosses it.
Do you have any other relevant info that you have not shared?
  댓글 수: 2
Elin Berntsson
Elin Berntsson 2017년 11월 27일
Well yes I have the two arrays of values, time and A(time). I also have an equation;
A(time)=A0*exp(-k*time)
I don't have a value for k, that is also something that i should calculate. The question says: Calculate A0 (value of A when the time=0) and k by plotting the values in the arrays;
Time=[0.5:0.5:5];
A=[1.2 0.73 0.45 0.27 0.16 0.11 0.06 0.035 0.022 0.013];
the cyclist
the cyclist 2017년 11월 27일
Fantastic.
If you take the log of each side of that equation, you get
log(A) = log(A0) - k*time
That's a linear equation that can be fit using the data you have, using the polyfit command.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by