two variables one equation 3D plot
显示 更早的评论
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 个评论
Dyuman Joshi
2021-11-25
编辑:Dyuman Joshi
2021-11-25
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
2021-11-25
Dyuman Joshi
2021-11-25
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
2021-11-25
Nickel Blankevoort
2021-11-25
编辑:Nickel Blankevoort
2021-11-25
Dyuman Joshi
2021-11-25
I can't see your code? Or did you mean, that you have included what I wrote in your code?
Nickel Blankevoort
2021-11-25
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
