two variables one equation 3D plot
Mostrar comentarios más antiguos
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 comentarios
Dyuman Joshi
el 25 de Nov. de 2021
Editada: Dyuman Joshi
el 25 de Nov. de 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
el 25 de Nov. de 2021
Dyuman Joshi
el 25 de Nov. de 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
el 25 de Nov. de 2021
Nickel Blankevoort
el 25 de Nov. de 2021
Editada: Nickel Blankevoort
el 25 de Nov. de 2021
Dyuman Joshi
el 25 de Nov. de 2021
I can't see your code? Or did you mean, that you have included what I wrote in your code?
Nickel Blankevoort
el 25 de Nov. de 2021
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
