I have an array of dimensions {n,M}, and for every nth curve generated, I want to color it using the “discrete” derivative information, that is to say, by using the slope of this linear-piecewise curve. For example, if the nth curve is
ncurve={1,2,3,3,2,4,2,1}
I would like to color the lines between the mesh points using the “derivative” array
If you show more data (ncurves) that will help with some MWE.
But for your derivatives, what you show does not look correct. Mathematica has a function for this that you should be using:
Please notice how Mathematica code is formatted on this site and follow this formatting.
About your question. I am not sure why are you complicating things - first let’s figure out how to do it for a single data set. Then you can generalize for all curves. Define a function: