Plot min values of one matrix on contour of another

조회 수: 2 (최근 30일)
Daniel
Daniel 2020년 5월 12일
댓글: Daniel 2020년 5월 14일
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.
  댓글 수: 1
Daniel
Daniel 2020년 5월 14일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by