Solving wave equation using matlab?
조회 수: 10 (최근 30일)
이전 댓글 표시

Using the analytical solution(attached), compute the solution for grid spacings of dx/L = (2^-5, 2^-7, 2^-9).(i.e. 33, 129 and 513 points). Choose your time-step such that the stability criteria is met for each grid spacing. Run your numerical solution for 2 cycles (t = 2T, where T is the period for one wave cycle of the 5th mode) and present a plot of the displacement at times, t = 0.5T; 1T; 1.5T; 2T. Each plot should compare the three grid spacings to the analytical solution. Comment on the accuracy of your numerical stencil. When presenting your results you should use at least n = 1000 points for your analytical solution so that the curve appears continuous.
c = 340 L = 0.09
I have attached my code to solve this question, it seems to give 4 graphs which all look the same? According to the qn, they should be different. Please clarify where the mistake is thanks!
댓글 수: 0
답변 (1개)
Ameer Hamza
2018년 4월 29일
You are getting this problem because of 4 plot statements at the end of your code are plotting same curves
plot(x,gnp1);
all 4 plot use same x and gnp1. You need to save each result individually in an array and plot. Alternatively, you can move plot inside for loop and plot the result of each iteration.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!