two variables one equation 3D plot
Ältere Kommentare anzeigen
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 Kommentare
Dyuman Joshi
am 25 Nov. 2021
Bearbeitet: Dyuman Joshi
am 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
am 25 Nov. 2021
Dyuman Joshi
am 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
am 25 Nov. 2021
Nickel Blankevoort
am 25 Nov. 2021
Bearbeitet: Nickel Blankevoort
am 25 Nov. 2021
Dyuman Joshi
am 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
am 25 Nov. 2021
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
