MATLAB: Function definitions are not permitted in this context

MATLAB

function assorted = LAB3Func(h)
h = 0:1:105;
while (h > 0) & (h < 11)
T = 288.16+ (-6.5*10^-3)*(h-0);
P = (1.01325*10^5)*(1+((-6.5*10^-3)/T)*(h-0));
D = 1.2250*(1+((-6.5*10^-3)/T)*(h-0));
h = h + 1;
end

Best Answer

You need to store that code in a file named LAB3Func.m
Note:
Your h is a vector, so (h>0) is a vector and (h<11) is a vector, so (h>0)&(h<11) is a vector. When you while or if a vector, the test is only considered to be true provided that all elements of the vector are non-zero, so your code is equivalent to
while all((h>0)&(h<11))
But one element of h is 0, so it is not true that all h > 0, and so your while loop body will never be executed.