필터 지우기
필터 지우기

Question about initial value problem

조회 수: 1 (최근 30일)
Zeynep Toprak
Zeynep Toprak 2020년 4월 21일
댓글: Ameer Hamza 2020년 4월 21일
I really do not understand what this question says to me. In those quarantina days, I am trying to learn matlab by myself by using Tobin's book. thus, I have no body to ask directly this question. Therefore, I posted this question without any my solution trial. sorry for that. any help, any suggestion any hint to give a way to solve this question will become very useful for me. Many thanks.

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 4월 21일
편집: Ameer Hamza 2020년 4월 21일
This question is similar to the one you posted earlier from this book, but this time, instead of giving a function handle as input, we are only giving vectors x and y. The interquad function does not know the input function and just need to rely on these data points to find the integral. To guess the value at a point, not in vector x, we use interpolation. Try the following code to
x = 0:0.01:1;
y = x.^2;
a = interquad(x, y);
function Q = interquad(x, y)
f = @(xq) interp1(x, y, xq, 'pchip'); % phicp is recommended instead of cubic
Q = quad(f, x(1), x(end));
end
It creates vectors x, and y from function on the interval . The output is as follow
a =
0.3333
It is same as integral of on interval 0 to 1.
  댓글 수: 2
Zeynep Toprak
Zeynep Toprak 2020년 4월 21일
Dear Hamza, your solutions are very useful. I saw similar auestion, but I am stack at it due to different function types. I dont knoe how to deal with this function type. but as a result of your great solution, I see it! really really thank you so much. And also, if you have time, please can you look at my any other question on boundary value problem. I want to see one example of boundary value problem in matlab. this is a good example in the book. can you help me to do this? My question so Link Many many thanks!
Ameer Hamza
Ameer Hamza 2020년 4월 21일
I am glad to be of help. Check my answer on that question.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by