필터 지우기
필터 지우기

I am unable run this code , can i know where is wrong

조회 수: 6 (최근 30일)
Saravana Kumar
Saravana Kumar 2022년 8월 1일
답변: Bhanu Prakash 2024년 7월 11일 9:42
function [theta_p, epsilon_max, epsilon_min, Y_max_in] = P_7_C6(-260,-60,480,0.334)
%
% Define average normal strain
epsilon_avg = ((epsilon_x + epsilon_y)/2);
%
% Calculate, Radius of the Mohr circle
R = sqrt(((((epsilon_x) - (epsilon_y))/2)^2) + ((Y_xy/2)^2) );
%
% Calculate maximum principal strain
epsilon_max = epsilon_avg + R;
%
% Calculate minimum principal strain
epsilon_min = epsilon_avg - R;
%
% Locate the position of the principal plane
theta_p = (atand((Y_xy)/ ((epsilon_x) - (epsilon_y) ) ) )/2;
%
% Calculate maximum in-plane shear strain
Y_max_in = 2*R;
%
% Define third principal strain along an axis perpendicular
% to the plane of stress.
epsilon_c = -(nu/ (1-nu) )* ((epsilon_max) + (epsilon_min));
%
% Calculate maximum shear strain
if (epsilon_max >= epsilon_min && epsilon_min >= epsilon_c)
Y_max_out = (epsilon_max) - (epsilon_c);
elseif (epsilon_max >= epsilon_c && epsilon_c >= epsilon_min)
Y_max_out = (epsilon_max) - (epsilon_min);
elseif (epsilon_c >= epsilon_max && epsilon_max >= epsilon_min)
Y_max_out = (epsilon_c) - (epsilon_min);
end
%
%Print the output values
fprintf([ '\nAngle between xy axes and principal axes ',...
'(+ Counter-clockwise) :' ])
fprintf([ * \n-------------------------------------------',...
'-------------------------\n' ])
fprintf( 'Principal plane is at %f Degrees \n' , theta_p)
fprintf (['epsilon_a = %d micro meter\nepsilon_b = %d micro ',...
'meter\n' ], epsilon_max, epsilon_min)
fprintf( 'epsilon_c = %5.2f micro meter \n', epsilon_c)
fprintf([ '\n--------------------------------------------- ,...
'---------------------\n' ])
fprintf(['Y_max(in-plane) = %5.2f micro radians',...
'\nY_max(out-of-plane) = %5.2f micro radians \n' ], Y_max_in, Y_max_out)
end

답변 (1개)

Bhanu Prakash
Bhanu Prakash 2024년 7월 11일 9:42
Hi Saravana,
The provided code has the following errors:
  • The arguments [epsilon_x, epsilon_y, Y_xy, nu] that you are using in the function 'P_7_C6' must be passed as input arguments to the function. Assuming that the values of [epsilon_x, epsilon_y, Y_xy, nu] are [-260, -60, 480, 0.334] respectively, the funciton signature can be modified as:
function [theta_p, epsilon_max, epsilon_min, Y_max_in] = P_7_C6(epsilon_x, epsilon_y, Y_xy, nu)
  • The character vectors in the 'fprintf' statements are not properly terminated.
Here is the modified code after resolving the errors:
function [theta_p, epsilon_max, epsilon_min, Y_max_in] = P_7_C6(epsilon_x, epsilon_y, Y_xy, nu)
%
% Define average normal strain
epsilon_avg = ((epsilon_x + epsilon_y)/2);
%
% Calculate, Radius of the Mohr circle
R = sqrt(((((epsilon_x) - (epsilon_y))/2)^2) + ((Y_xy/2)^2) );
%
% Calculate maximum principal strain
epsilon_max = epsilon_avg + R;
%
% Calculate minimum principal strain
epsilon_min = epsilon_avg - R;
%
% Locate the position of the principal plane
theta_p = (atand((Y_xy)/ ((epsilon_x) - (epsilon_y) ) ) )/2;
%
% Calculate maximum in-plane shear strain
Y_max_in = 2*R;
%
% Define third principal strain along an axis perpendicular
% to the plane of stress.
epsilon_c = -(nu/ (1-nu) )* ((epsilon_max) + (epsilon_min));
%
% Calculate maximum shear strain
if (epsilon_max >= epsilon_min && epsilon_min >= epsilon_c)
Y_max_out = (epsilon_max) - (epsilon_c);
elseif (epsilon_max >= epsilon_c && epsilon_c >= epsilon_min)
Y_max_out = (epsilon_max) - (epsilon_min);
elseif (epsilon_c >= epsilon_max && epsilon_max >= epsilon_min)
Y_max_out = (epsilon_c) - (epsilon_min);
end
%
%Print the output values
fprintf([ '\nAngle between xy axes and principal axes ',...
'(+ Counter-clockwise) :' ])
fprintf([ '\n-------------------------------------------',...
'-------------------------\n' ])
fprintf( 'Principal plane is at %f Degrees \n' , theta_p)
fprintf (['epsilon_a = %d micro meter\nepsilon_b = %d micro ',...
'meter\n' ], epsilon_max, epsilon_min)
fprintf( 'epsilon_c = %5.2f micro meter \n', epsilon_c)
fprintf([ '\n---------------------------------------------' ,...
'---------------------\n' ])
fprintf(['Y_max(in-plane) = %5.2f micro radians',...
'\nY_max(out-of-plane) = %5.2f micro radians \n' ], Y_max_in, Y_max_out)
end
You can now call the function with the required values like this:
[theta_p, epsilon_max, epsilon_min, Y_max_in] = P_7_C6(-260, -60, 480, 0.334);

카테고리

Help CenterFile Exchange에서 Digital Filter Analysis에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by