MATLAB: Is Meshgrid Command not working with decimal values

3d plotsmeshgridplotting

%Meshgrid command
%This is working fine.
[f,N]=meshgrid(1:2,400:1100);
t=8;
D=10;
F= 1.807068 - (0.045290*t) -(0.042802*D) -(0.000136*N) -(0.160279*f)+ (0.000008*t.*N)+(0.000278*N.*f)+(0.001046*t.*t)+(0.001946*D.*D)+(1.448602*f.*f);
mesh(f,N,F);
%but this not working. All I am changing is putting decimal values of "f"
[f,N]=meshgrid(0.1:0.2,400:1100);
t=8;
D=10;
F= 1.807068 - (0.045290*t) -(0.042802*D) -(0.000136*N) -(0.160279*f)+ (0.000008*t.*N)+(0.000278*N.*f)+(0.001046*t.*t)+(0.001946*D.*D)+(1.448602*f.*f);
mesh(f,N,F);

Best Answer

Meshgrid DOES work. At least when used properly. :) Your problem here is not with meshgrid.
I think what you did was to assume that simply scaling everything in your code would result in the same result. That may not always be a bad assumption, but it is dangerous to do without thinking about what you are doing. What you forgot to think about were defaults for functions and operators. Here colon is important.
What do you expect this to do in MATLAB?
0.1:0.2
TRY IT! How does that compare to what you will get from this:
1:2
Or this?
0.1:0.1:0.2
Or this?
0.1:1:0.2
Do you expect all of them to produce vectors of length 2?
The point is, no matter what the end points of a colon operation, it uses a step of 1 if no step is provided. If that step will take you past the end point, then colon generates a truncated sequence.
For example:
1:2:4
ans =
1 3
See that colon does NOT generate the vector [1 3 4], including the end point.
Given that, you can see why 0.1:0.2 does what it does, because that is equivalent to
0.1:1:0.2
with an implicit step of 1.
(Honestly, I think this should be explained in great detail in the help docs for colon. That might help at least a few people, though most will never see it, at least until they know the answer already. But then, I tend to be a compulsive, perfectionist documenter.)