Update: I've made some progress on this. I found that you can return the ContourMatrix from the contour function in order to get the curves of constant "Z" that Matlab determines. I've also downloaded the C2xyz function in order to get the x and y values that correspond to the ContourMatrix. Sometimes, what I need, however, are the indices. It kind of works to do something along the lines of min(abs(x-x')) where x is the original matrix I have and x' are the values returned from C2xyz. It can be a bit coarse, though, so I may try to do some interpolation to get a higher "sampling rate" of my original matrices.
Plot min values of one matrix on contour of another
2 views (last 30 days)
Show older comments
I have two matrices that are each made as functions of the same two variables. So say they are A(x,y) and B(x,y). I don't know the actual functions; I just have the matrices. Apologies, but I cannot provide my data and I'm not savvy enough to create something representative, but they look like this:
I'm trying to figure out how to plot the min(B) (the right plot) on the contour(A) (the left plot). That is, given a value of A, what is the minimum B that achieves it and then plot the (x,y) that correspond to that minimum B on the contour of A. There's a first difficulty of defining curves of constant-ish A since it is defined by regular intervals of x and y, not A. I think I've solved that by finding the indices of A that are equal to A +/- delta, where delta is a small value. Delta is not easily defined, though, because making it smaller reduces the chance of there being multiple x's for a given y or vice versa that satisfy the condition and making it larger yields a more continuous curve to work with. I think another issue is that for many values of A, B is double-valued, and so there may need to be an additional requirement of taking the shortest path, though defining different options could be interesting. For example, starting at the plus on the right plot, the minimum B (right plot again) for a given A (left plot) could move mostly left on B or sort of up and right, I think. Please ask questions if this is not clear. I realize this would be much easier with the data I'm using, but I'm not allowed to share it. Thanks.
Answers (0)
See Also
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!