Visualizing functions of 2 variables:
Ältere Kommentare anzeigen
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 Kommentare
Walter Roberson
am 15 Okt. 2012
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
am 15 Okt. 2012
Bearbeitet: Enfa White
am 15 Okt. 2012
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Spline Postprocessing finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!