Info

此问题已关闭。 请重新打开它进行编辑或回答。

Difference between lines coding

1 次查看(过去 30 天)
Eddy Ramirez
Eddy Ramirez 2020-10-18
关闭: MATLAB Answer Bot 2021-8-20
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

回答(1 个)

Prudhvi Peddagoni
Prudhvi Peddagoni 2020-10-22
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.

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by