Right, in Matlab 7.9.0 this gives the following more useful error:
Error using ==> surf at 78
Z must be a matrix, not a scalar or vector.
Error in ==> testforcp at 43
surf(pxw1);
(testforcp is just the name of the file I've put your code in).
This tells me that you need to review what you're passing to
surf
.
I think the problem is here:
[x,y]=meshgrid(-3*sd1:1:3*sd1, -3*sd2:1:3*sd2)
-3*sd1:1:3*sd1
evaluates to -0.2476, not a list. This causes x and y to become scalers, and it all goes wrong from there.
If I changed it to
-3*sd1:0.001:3*sd1
, (be warned, took a relatively long time to execute on my Uni servers...) I received a graph out. I hope this helps track down what to fix.
Just a couple of notes:
0. Put code in <pre> or <code> tags (use the 'code block' or 'inline code' buttons respectively).
1. Look in to
numel
to improve this line:
for(i=1:6)
2. At the moment you'll only see the last graph, as each
surf
overwrites the previous one. Either look in to putting all the plots on to one page, or use the
pause
command to make Matlab wait for any key press between each plot.
I hope this all helps.