Visualizing functions of 2 variables:
显示 更早的评论
I wish to perform a 3D graph using surf:
How use the following 8 by 3 matrix as my input values for a and b:
2.12345 2.12345 2.12345 % row 1
2.12345 2.12345 3.12345 % row 2
2.12345 3.12345 2.12345 % row 3
2.12345 3.12345 3.12345 % row 4
3.12345 2.12345 2.12345 % row 5
3.12345 2.12345 3.12345 % row 6
3.12345 3.12345 2.12345 % row 7
3.12345 3.12345 3.12345 % row 8
My function is as follows:
function my_func = z(~,~)
x = (1+sin(5*a)-(1/sqrt(8*(sin(a)))))
y = (1+sin(5*b)+(1/sqrt(8*(sin(b)))))
z = x+y+x
Please help me to add a loop into my function, so that the first loop will accept the first row as input and so on. Also help me to correct the function, my intended input and output are:
Sample input:
2.12345 2.12345 2.12345 % row 1
Sample output based on row 1 input:
x = (1+sin(5*2.12345)-(1/sqrt(8*(sin(2.12345)))))
y = (1+sin(5*2.12345)+(1/sqrt(8*(sin(2.12345)))))
x = (1+sin(5*2.12345)-(1/sqrt(8*(sin(2.12345)))))
z = x+y+x
To plot the 3D graph:
% what should I put here as x and y values here?
surf(x,y,z)
anything else should I add to plot the 3D graph ?
2 个评论
Walter Roberson
2012-10-15
You have 3 input values per row. How do you want to covert those three values into the two variables "a" and "b" ?
Your function shows you calculating x then y then x+y+x . Is that the same as (2*x)+y ? I ask because your sample output shows three outputs, x then y then x, after which x+y+x becomes suggestive that perhaps you failed to show a line of calculation and also accidentally named two variables "x".
Enfa White
2012-10-15
编辑:Enfa White
2012-10-15
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Spline Postprocessing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!