Error when trying to run a function using a script file.

I had to create a function and then run that function using a script file. Both files are saved in the current working folder. And if I call the function in the command window it works.
the function code is:
function [ Ot,Or,R ] = prob1_fun( Ri,Ro,Pi,Po )
%Calculates the tangential and radial stresses of a cylinder as a function
%of R (the radius at the point to be analyzed)
% List of Variables:
% Ot = tangenential stress (psi)
% Or = radial stress (psi)
% R = radius at point to be analyzed (in)
% Ri = inner radius of the cylinder (in)
% Ro = outer radius of the cylinder (in)
% Pi = pressure on inner surface of cylinder (psi)
% Po = pressure on outer surface of cylinder (psi)
%Constraints
R = linspace(Ri,Ro,((Ro-Ri)/0.1)); %R spans the distance between Ri and Ro at increments of one tenth the difference between Ri and Ro.
%Parameter Equations: Two more variables are created to make the code
%easier to comprehend and read. These variables simply break the code into
%two smaller equations that are defining parts in both stress calculations.
%They serve no purpose other than making the code easier to write and to
%read.
K1 = (Pi*(Ri^2) - Po*(Ro^2)) / ((Ro^2) - (Ri^2));
K2 = ((Pi-Po)*(Ro^2)*(Ri^2)) / ((Ro^2) - (Ri^2));
%Final Stress Equations:
Ot = K1 + (K2 ./ (R.^2)); %tangenential stress (psi)
Or = K1 - (K2 ./ (R.^2)); %radial stress (psi)
end
the script code is:
%Variables:
% Ri = inner radius of the cylinder (in)
% Ro = outer radius of the cylinder (in)
% Pi = pressure on inner surface of cylinder (psi)
% Po = pressure on outer surface of cylinder (psi)
%Defining Parameters:
Ri = 2; %inches
Ro = 4; %inches
Pi = 1000; %psi
Po = 100; %psi
%Calculations
[Tangential_Stress,Radial_Stress,Radius_Analyzed] = probl_fun (Ri,Ro,Pi,Po);
and I get the following error when trying to run the script file in the command window of matlab:
>> run prob1_script
Undefined function 'probl_fun' for input arguments of type 'double'.
Error in prob1_script (line 29)
[Tangential_Stress,Radial_Stress,Radius_At_Point_Analyzed] = probl_fun (Ri,Ro,Pi,Po);
Error in run (line 64) evalin('caller', [script ';']);

 Respuesta aceptada

per isakson
per isakson el 15 de Feb. de 2014
Lower case "L" is a tricky letter.
The name of your function is prob1_fun with the digit "1" and in the script you try to call probl_fun with the letter "l".

Más respuestas (0)

Categorías

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

Preguntada:

el 14 de Feb. de 2014

Respondida:

el 15 de Feb. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by