For Loop maximum graph

조회 수: 4(최근 30일)
Patrick Monst
Patrick Monst 2022년 4월 8일
답변: DGM 2022년 4월 8일
given a matrix C, i am to find the values of x and y where the plot of C is at max. whenever i run a code that uses the find function, i am returned with the row and column of the element in the matrix instead, and not the x and y points of the graph. any idea how to fix this?
댓글 수: 1
Davide Masiello
Davide Masiello 2022년 4월 8일
Could you please share your code?

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

답변(1개)

DGM
DGM 2022년 4월 8일
Idk why membrane doesn't allow for the x,y data to be an output argument, but it doesn't. You can just create them anyway.
m = 15;% this is the default
xy = linspace(-1,1,2*m+1);
C = membrane(1,m);
[mxz, idx] = max(C(:));
[r, c] = find(C == mxz);
maxpoints = [xy(c) xy(r) mxz]% [x y z]
maxpoints = 1×3
0.3333 -0.3333 1.0000
surf(xy,xy,C); holdon;
plot3(maxpoints(1),maxpoints(2),maxpoints(3),'ko','markersize',15)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by