two variables one equation 3D plot
Afficher commentaires plus anciens
Dear,
I have two input vector matrices as variables alf and gam:
alf = [0, 0.03, 0.1, 0.5, 1, 1.5];
gam = [0, 0.03, 0.1, 0.5, 1, 1.5];
Then I have some complicated steps resulting in one value for each possible combination of the two variables alf and gam.
For example alf=0.03 and gam=1 gives one answer. And alf=0.5 and gam=0 gives an other answer etc.
How can I plot this as a 3D plot with a surface with alf and gam as X and Y axes and the outcome Z axis.
if I try:
[gamM, alfM]=meshgrid(gam,alf);
surf(gamM,alfM,log10(T))
it gives me the error saying:
Error using surf (line 71)
Z must be a matrix, not a scalar or vector.
kind regards Nickel
7 commentaires
Dyuman Joshi
le 25 Nov 2021
Modifié(e) : Dyuman Joshi
le 25 Nov 2021
You might be storing T as row/column vector. Change it into a matrix.
Since you mentioned that you get a unique output for each gam and alf, then your T should have 36 elements. Convert it into a 6x6 matrix and try again.
Nickel Blankevoort
le 25 Nov 2021
Dyuman Joshi
le 25 Nov 2021
for i=1:numel(alf)
for j=1:numel(gam)
T(i,j)= alf(i)*gam(j) %this is just an exmample, use your existing formula
end
end
Nickel Blankevoort
le 25 Nov 2021
Nickel Blankevoort
le 25 Nov 2021
Modifié(e) : Nickel Blankevoort
le 25 Nov 2021
Dyuman Joshi
le 25 Nov 2021
I can't see your code? Or did you mean, that you have included what I wrote in your code?
Nickel Blankevoort
le 25 Nov 2021
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur MATLAB 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!
