Surface plot positive output and corresponding combination of variables only
Afficher commentaires plus anciens
I have a function with two variables over a range and wish to find all possible combination of the variables that will return positive output (>0).
Say the function is 2x-3y, and x and y is defined as
length_L = 0.0001:0.0001:0.005;
length_R = 0.0001:0.0001:0.005;
and all combinations of length_L and length_R is apply to the function by
[X, Y] = meshgrid(length_L, length_R);
F = 2*X-3Y;
which will return a matrix F which is the result of all combination of length_L and length_R, which can be visualize with
surf(length_L, length_R, F)
% or
surf(X, Y, F)
However, I only want to show the positive F value and the combination of two variables that will result it.
I had tried some logical indexing that I am certain are incorrect like
posF = F(F>0);
posX = X(F>0);
posY = Y(F>0);
surf(posX, posY, posF)
But does not work at all as posF, posX and posY are all vector and surf(X, Y, Z) the Z need to be in matrix.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Surface and Mesh Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
