I have looked over my code and can't find the problem. It has given me two errors, one when I was stepping through to try and find the issue:
"Unrecognized function or variable 'L' Error in MatlabHW_1 (line 46)" and when I ran it normally it gave me the fsolve error: "Error in fsolve (line 255)
fuser = feval(funfcn{3},x,varargin{:});"
I am not sure what this means and I haven't found any documentation on it, but for context here is my code:
function nacelle()% *Constants:*
sigma = 5.67e-8; %Stephan Boltzman constant
% *Variables:*
efficiency = 0.93; %efficiency
A_gen = 4.2; %[m^2] generator surface area
epsilon = 0.8; %emissivity
T_inf = 30+273.15; %[K] air temperature
power = 2.5e6; %[W] generator power
% *Set up array for temperature:*
h = linspace(30,80,10); %array for increasing heat transfer coefficient
L = length(h); %find length of coefficient data
T = zeros(L,1); %set up temperature vector
%%
options=optimset('Display','off'); % Publishing purposes only Option to display output
for i=1:L T = fsolve(@(T) thefunct(T, epsilon, efficiency, T_inf, A_gen, power, sigma, h(i)), 300, options); T_s = T-273.15; %convert to celsius
end%% Plot and Results
plot(h,T_S)xlabel('Heat Transfer coefficient [W/(m^2*K)]')ylabel('Surface temperature [C]')title('Wind Turbine Generator in Nacelle')set(gca,'FontSize',14)end%%
% *Residual function for finding temperature*
function Res = thefunct(T, epsilon, efficiency, T_inf, A_gen, power, sigma, h) Res = power - (h*A_gen*(T_S-T_inf)+sigma*A_gen*T_s^4+efficiency*power); end
Best Answer