Surface plot positive output and corresponding combination of variables only
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Kai Jie See
il 28 Dic 2020
Commentato: Kai Jie See
il 29 Dic 2020
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.
0 Commenti
Risposta accettata
Cris LaPierre
il 28 Dic 2020
What about setting the F values that are <=0 to NaN?
length_L = 0.0001:0.0001:0.005;
length_R = 0.0001:0.0001:0.005;
[X, Y] = meshgrid(length_L, length_R);
F = 2*X-3*Y;
F(F<=0) = nan;
surf(X, Y, F)
3 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Surface and Mesh Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
