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!