MATLAB Answers

Difference between lines coding

1 view (last 30 days)
Eddy Ramirez
Eddy Ramirez on 18 Oct 2020
Answered: Prudhvi Peddagoni on 22 Oct 2020
Greetings,
I am running the attached coding (run HW2W1) and I need to develop a code that will find the difference between points along the lines for the two lines for each graph. I am assuming the code will be the same for all three and I just have to adjust the file that I am referring.
For example, If i want to find out the difference between the two lines at 1.2 or finding out the difference between the two lines at -2.5.
thank you any help would be greatly appreciated it

Answers (1)

Prudhvi Peddagoni
Prudhvi Peddagoni on 22 Oct 2020
Hi,
In the HW2W1.m file, you have (W1X,W1Y) and (W1xCI,WlyCL) variables(from HW2_P1_W1.txt). so you want to find the difference between the lines ploted by these two variable sets (x,y). but the problem is that the size of W1X and W1xCl is different.
You can use interp1 function interpolate the data for the 2nd plot. Then you can see the difference between the two plots
WlyCL_new=interp1(W1xCl,wlyCL, W1X)% this calculates the values of all y co-ordinates for W1X x-coordinates
wlxCl_new=W1X
%for finding the difference between the 2 plots at -1, you need to find -1 in W1X
%let it be idx
diff=W1Y(idx)-WlyCL(idx); % this gives the difference between two lines.
hope this helps.

Tags

Community Treasure Hunt

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

Start Hunting!