Requires more input arguments to run

I just bought MatLab for a school project a few hours ago, and I've never used this software before. I need to run the code my professor has posted, but the message "'convection_hat' requires more input arguments to run" comes up. Is there something wrong with the code she posted? I'd really appreciated any help, as I'm totally lost at the moment. Here is the code:
function d_theta_hat = convection_hat( t, theta_hat_vec )
global F N tol del_x del_y lap_inv;
% theta_hat = Fourier transform of Theta given in ODE call.
% t = time
% return Fourier Transform of -u \cdot \grad theta
% where v = -\lap \inv P ( \theta \cdot \grad \inv \theta )
% and u = v / \norm{\grad v}_{L^2}
theta_hat = reshape( theta_hat_vec, N, N );
% g = \theta \grad\inv \theta
% To convolve accurately we need to "circularly" convolve, which matlab
% doesn't have in 2D. Instead we ifft, multipliy and fft back.
linv_theta_hat = lap_inv .* theta_hat;
theta = ifft2( theta_hat, 'symmetric' );
g_hat(:, :, 1) = fft2( theta .* ifft2( del_x .* linv_theta_hat, 'symmetric' ) );
g_hat(:, :, 2) = fft2( theta .* ifft2( del_y .* linv_theta_hat, 'symmetric' ) );
% div_g_hat = (\divergence g)^\hat
div_g_hat = del_x .* g_hat(:, :, 1) + del_y .* g_hat( :, :, 2 );
% v = -\lap\inv P g
v_hat(:, :, 1) = -lap_inv .* ( g_hat(:,:,1) - del_x .* lap_inv .* div_g_hat );
v_hat(:, :, 2) = -lap_inv .* ( g_hat(:,:,2) - del_y .* lap_inv .* div_g_hat );
v_hat_norm1 = del_x.*v_hat(:,:,1);
v_hat_norm2 = del_x.*v_hat(:,:,2);
v_hat_norm3 = del_y.*v_hat(:,:,1);
v_hat_norm4 = del_y.*v_hat(:,:,2);
norm_v_hat = sqrt( norm( v_hat_norm1(:), 2 )^2 + ...
norm( v_hat_norm2(:), 2 )^2 + norm( v_hat_norm3(:), 2 )^2 + ...
norm( v_hat_norm4(:), 2 )^2 );
norm_v = norm_v_hat / N^2; % L2 conversion factor for DFT.
% Compare norm_v relative to norm_g
linv_g_hat( :, :, 1 ) = lap_inv .* g_hat(:, :, 1);
linv_g_hat( :, :, 2 ) = lap_inv .* g_hat(:, :, 2);
norm_linv_g = norm( linv_g_hat(:), 2 ) / N^2;
if norm_v < norm_linv_g *tol;
disp( sprintf( ...
'Possible saddle point: t=%.3f, norm_v=%.9f, norm_g=%.9f', ...
t, norm_v, norm_linv_g ) );
end
u(:, :, 1) = F*ifft2( v_hat(:, :, 1), 'symmetric' ) / norm_v;
u(:, :, 2) = F*ifft2( v_hat(:, :, 2), 'symmetric' ) / norm_v;
d_theta_hat = -fft2( ...
u(:,:,1) .* ifft2( del_x.*theta_hat, 'symmetric' ) + ...
u(:,:,2) .* ifft2( del_y.*theta_hat, 'symmetric' ) );
% Finally we need our output to be used in ode23 or ode45 functions, so we
% need reshape it.
d_theta_hat = d_theta_hat(:);
end

3 comentarios

per isakson
per isakson el 1 de Ag. de 2014
Exactly how did you try to run the function, convection_hat. Don't let us guess!
Adam
Adam el 1 de Ag. de 2014
I'm sorry, but I'm not exactly sure what you mean. I'm not familiar at all with how this software works, but I just clicked the green "run" button and the message "convection_hat requires more input arguments to run: convection_hat(t, theta_hat_vec)." I apologize. I'm not sure if I've clarified anything.
per isakson
per isakson el 1 de Ag. de 2014
Editada: per isakson el 1 de Ag. de 2014
Your professor obviously chose not to make it that simple for you. Didn't she provide some additionally instruction?
See Run Functions in the Editor and run study the examples.

Iniciar sesión para comentar.

 Respuesta aceptada

Hikaru
Hikaru el 1 de Ag. de 2014

1 voto

What did you type before you get that error message? You need to define the values for t and theta_hat_vec

4 comentarios

Adam
Adam el 1 de Ag. de 2014
Oh, I see. Again, I'm sorry for asking such a trivial thing, but under the "Run" button, where it says "type code to run", I entered something like convection_hat(5,5), for example. I tried this, but now a new message comes up saying "Syntax error, convection_hat cannot run as it appears"
Hikaru
Hikaru el 1 de Ag. de 2014
I think the second input argument, theta_hat_vec, should be a vector. Is this the only code provided by your professor? Maybe you could re-read the assignment and see if she mentioned how to find the values for theta hat.
Adam
Adam el 1 de Ag. de 2014
Yes, unfortunately this is the only code provided. There also seems to be a problem when I try running it as convection_hat(5,[,5 5]), which from what I've read, is how you'd right a vector in Matlab. Thank you for your help though. Much appreciated!
Hikaru
Hikaru el 1 de Ag. de 2014
Technically, you also need to know the values for the global variables (F, N, tol, del_x, del_y, and lap_inv) before this code could run.
Good luck with the school project.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 1 de Ag. de 2014

Comentada:

el 1 de Ag. de 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by