필터 지우기
필터 지우기

Requires more input arguments to run

조회 수: 1 (최근 30일)
Adam
Adam 2014년 8월 1일
댓글: Hikaru 2014년 8월 1일
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
Adam
Adam 2014년 8월 1일
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 2014년 8월 1일
편집: per isakson 2014년 8월 1일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Hikaru
Hikaru 2014년 8월 1일
What did you type before you get that error message? You need to define the values for t and theta_hat_vec
  댓글 수: 4
Adam
Adam 2014년 8월 1일
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 2014년 8월 1일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by