I have a vector of data points, and I'd like to be able to selectively plot just a portion of that vector. For example, I have a vector value:=[2 3 5 8 13 21] and I want to plot just elements 2, 3, and 4. I created an index:=[2 3 4] and tried to plot value[index on the vertical axis. I've tried both the chart component and the native plotting tool, and neither worked. The only way I've figured out how to do this is to write a mathcad program to fill a third vector with just the portion that I wish to plot, then plot that third vector. That's awkward. Can you tell me what I'm doing wrong?
Solved! Go to Solution.
The key is the submatrix statement to extract a region of the vector.
Good to know about the submatrix function. Thanks!
In hindsight, I like this solution better for my application. It's a bit cleaner.
Thanks!
@terryhendicott wrote:
The key is the submatrix statement to extract a region of the vector.
But that only works if the values in the "index" vector are in sequential order without any value missing in-between. This may be the intention of @MJ_10071773 (at least the values in his example vector "index" are in sequential order) but we cannot be absolutely sure about it.
A small user defined function can be used for more versatility and this function also could be useful in other situations as well.
I used a modified vector "index" (2;3;5) to demonstrate the function.
I wonder why you created the vector "values" in such a cumbersome way!?
Sure could be done easier (and actually you did when you defined "index").
Prime 11 sheet attached
It was my intention that the indices would be sequential. Sometimes I want to plot the full vector, and sometimes I want to eliminate the first data point, the last data point, or both.
I defined the vector one datapoint at a time because I was debugging my issue one step at a time. In my actual work, each datapoint is generated one point at a time and assigned to a results vector and I wanted to be sure that I wasn't doing something wrong by indexing the datapoints one at a time. Thank you for showing me stack() and Ctrl-M.
Nice Fibonacci routine!
For vector entry, I sometimes indulge in creating a row vector and then transposing it. Save all that unnecessary waste of vertical whitespace.
Oh, and I've added a couple of Fibonacci generators just for something to fill up that whitespace with ....
Stuart
Of course, one wouldn't need the auxiliary function if Mathcad Prime didn't have a bug that prevented recursive local functions from working.
However, I believe that all of the above should work under Mathcad Prime Express ... as I might find out in 23 days!