Act FunctionsProblems
Act FunctionsProblems
function y = YenX(x)
y = ((-0.2.*x.^3) + (7*x.^2)).* exp(-0.3.*x);
>> YenX(-1.5)
ans =
25.7595
>> YenX(5)
ans =
33.4695
% (b)Use the function to make a plot of the function for -2 <= x <= 6
x = -2:0.1:6;
for i = 1:1:length(x)
a = x(i);
y(i) = YenX(a)
end
plot(y,x)
xlabel('X')
ylabel('Y )
% EXERCISE 2: Convert gal/mi to L/km
function Lkm = LkmtoGal(gmi)
>> LkmtoGal(5)
5.00 gal/mi are 11.76 L/km
ans =
11.7605
>> LkmtoGal(5.8)
5.80 gal/mi are 13.64 L/km
ans =
13.6422
% Exercice 3: Expression p
function p = expressionP(c,d,x)
p = ((c.*x)+(2.*d))./((c.*x)-d);
% Exercice 3: Expression q
function q = expressionQ(x,y,z)
>> Expresions_Evaluateing_2_noviembre_2023
f = sqrt((1./(0.01.*c))-((100.^2)./(4.*c.^2)));
% Values for c
c = 0.1:0.1:1;
fprintf('The inductance is 0.01 mH\n')
fprintf('The resistence is 100 ohms\n')
fprintf('The Frequenncy of ocillation is:')
FrecuOsc(c)
>> FrecuencyOscillation_2_noviembre_2023
ans =
1.0e+02 *
Columns 1 through 6
Columns 7 through 10