Question: 1 ) discretize space and time ( 1 0 points ) - space variable x: start value 0 , end value 1 0 e -
discretize space and time points
space variable x: start value end value e interval e
time variable t : start value end value e number of points
generate data points
compute values for p for each location and each time instance
recall:
all locations are stored in the array x created in
all time instances are stored in the array t created in
to generate the data and store it in a d array p follow these steps:
allocate and initialize a d array called p with as many rows as you
have points in space and as many columns as you have time instances
loop over all time instances and at each time instance loop over all x
locations hint: nested loops
use the loop variable it for looping over
the time instances and loop variable i for the loop over the x locations
for each it and i compute piit as
p expxcospixexsxpiet
expxcospixexsxpiet
cospixexsxpiet
expxcospixexsxpiet
write data to file points
write the data in binary format to a file with the name data.bin
write the data in the following format
column : x
columm : t
column : p
write out the data in double precision format
note: p had nt columns, only write nt columns to the file
visualize data points
generate a subplot with rows figures in total
in the first row plot the values of p for i over time
in the second row plot the values of p for it and over x
customize the plots as follows
increase the linewidth to pts
set the font size to
switch on the grid
for the plot in row :
set the xaxis label to t and the yaxis label to p
set the xaxis limits from to e
set the yaxis limits from to
for the plot in row :
set the xaxis label to x and the yaxis label to p
set the xaxis limits from to e
set the yaxis limits from to
add a legend to the figure with the labels and
for the four curves plotted in this graph
generate a figure file named projectmatlabfigure.png
Matlab Code
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
