Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PLOTTING IN MATLAB For this challenge we will plot experimental and theoretical

ID: 3878405 • Letter: P

Question

PLOTTING IN MATLAB For this challenge we will plot experimental and theoretical data on the same plot. Theoretical data (equation of a line) is true for any point so it should be plotted as a line, whereas experimental data is only true for a given point so it should be represented as a point. Use help to determine how to create a solid line: Use help to determine how to create points: a.) Write a program called plotPractice.m that creates a plot of the function y-cos(2Tx/L) over the range of 0 to 6 with 100 values. Use L=5 for the plot you turn in today. Include labels for the axes and a title b.) Then, plot the experimental data on the same axis with the function from part a) for the following x values: xexp [ 1, 2, 3, 4, 5] Use a single plot command for all trials. connecting line because it is experimental data. Hint: It's important to distinguish the 3 trials in your plot from one another in some way. Data from part b) should be added as points without any Trial! Trial2 Tria!3 = = = [0.38, [0.36, [0.22, -0.82,-0.79, 0.28, 0.93); -0.8, -0.88, 0.45, 1.1); -0.67, -0.94, 0.27, 0.98); Include all labels, axes, titles, and legends necessary. Make sure all markers are distinguishable by changing style of marker and color.

Explanation / Answer

solid line can be created using - style specifier

points can be created using . marker specifier

a)

plotPractice.m:

xlabel('x = 0:6')

ylabel('Cosine')

title('Plot of the Cosine Function','FontSize',12)

% create 100 linearly spaced values between 0 to 6

x = linspace(0,6,100);

y = cos(2*pi*x/5);

plot(x,y,'-r') % - is added to plot a solid line

b)

xlabel('X')

ylabel('Cosine')

title('Plot of the Cosine Function','FontSize',12)

Plot experimental daata on the same axis with following x values: xexp=[1,2,3,4,5] use below statement:

x = linspace(1,5,5);

y = cos(2*pi*x/5);

plot(x,y,'.') % . is added to plot as points without aby connecting lines

Trial1 = xticks([0.38 -0.82 -0.79 0.28 0.93])

y = cos(2*pi*Trial1/5);

plot(Trial1,y,'--b*')

Trial2 = xticks([0.36 -0.8 -0.88 0.45 1.1])

y = cos(2*pi*Trial2/5);

plot(Trial2,y,':g^')

Trial3 = xticks([0.22 -0.67 -0.94 0.27 0.98])

y = cos(2*pi*Trial3/5);

plot(Trial3,y,'-.m+')

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote