two variables one equation 3D plot
Show older comments
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 Comments
Dyuman Joshi
on 25 Nov 2021
Edited: Dyuman Joshi
on 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
on 25 Nov 2021
Dyuman Joshi
on 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
on 25 Nov 2021
Nickel Blankevoort
on 25 Nov 2021
Edited: Nickel Blankevoort
on 25 Nov 2021
Dyuman Joshi
on 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
on 25 Nov 2021
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!