Good Morning,
I am having a little trouble with my for loop and was hoping someone would be so kind to assist me. Given a set of data (x and y) I am trying to add or subtract some type of factor (SF) depending on the value of y (if y is negative add SF, if y is positive subtract SF). Currently, the for loop works only one transition (y value negative to positive or positive to negative) and not for more than one (positive to negative back to positive). Can anyone help or advise me how to fix my for loop to meet this requirement?
Thanks so much,
x=[808.284900000000809.904900000000811.672700000000813.550100000000815.487700000000817.448500000000819.423900000000821.410000000000823.402300000000825.398000000000827.395300000000829.393300000000831.391000000000833.387900000000835.383400000000837.377400000000839.369600000000841.360100000000843.349500000000845.338100000000847.327900000000849.319400000000851.308000000000853.282900000000855.228400000000857.128500000000858.966900000000860.726800000000862.391200000000863.942900000000865.363700000000866.635600000000867.755100000000868.739100000000]y=[-0.816189993942800-0.622532051258187-0.465001282100469-0.348391977260414-0.261473638062749-0.191273590942197-0.132866762880952-0.0881180486304432-0.0533090231370573-0.0252337776469318-0.002069073697056160.01847692976994370.03478154268285060.04818621322268010.05953673048308280.06560457197967710.06940171953610850.07560865242334730.08345934322107340.09433190893329690.1107833696455010.1331364528587680.1647664762871600.2135113966243370.2838540015405910.3774114577272380.4858758046869400.6086880852704190.7528084992975500.9163897426943521.108813247599901.348954949960451.628779230913201.92595565865132];d1=1.96707649837704;SF=d1/length(x);for i=1:length(y)SF=d1/length(x);if y(i) < 0 y(i)=y(i)+SF;elseif y(i) > 0 y(i)=y(i)-SF;endend
Best Answer