Solving wave equation using matlab?

10 visualizaciones (últimos 30 días)
Preets12
Preets12 el 29 de Abr. de 2018
Respondida: Ameer Hamza el 29 de Abr. de 2018
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!

Respuestas (1)

Ameer Hamza
Ameer Hamza el 29 de Abr. de 2018
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.

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by