Hi, I've got a function that I'm trying to define, it works for n=0 and n=1 but when I run it for n=2 I keep getting the error matrix dimensions must agree, i cant see what im doing wrong so any help would be great
The question i was given asked me to evaluate a function, and make sure it was adptable so that if it receives vectors of x and y it returns z as a 2D array.
function z = F(n,x,y)% F Write a comment here that summarises what the function does.
% Write your code for the "F" function here.
[X,Y] = meshgrid(x,y);if n==0 z = ones(10);elseif n==1 z = (0.5.*X)-Y.^2;else z = 2.*n.*X.*Y.*F((n-1),X,Y)-((2.*n)+1).*F((n-2),X,Y); z = z./(2.*n.^2);endend
Best Answer