Say I have a function
function u = somefxn(f,n)
where f
is some function, say f = pi^2*sin(pi*x)
, and n is the number of discretizations (let n = 1024
) on the interval $[0,1]$. In my code I've written
h = 1/n %n = 1024
x = 0:h:1 %discretizations
But what if the user uses y
or z
in the function instead of x
? How do I handle that uncertainty?
Please let me know if this isn't clear. I'm rather new to Matlab.