How to call a function
Afficher commentaires plus anciens
I have an assignment that asks for one function that uses user input to compute outputs to different questions. my code follows,
clear,clc,close all
function [C1, C2, C3, C4, C5, s, m] = Spring(f, i)
% start of homework #3 function
%access question #1 subfunction
m = convert(f);
%access question #2 subfunction
s = sum(i);
%code for question #3
%% Question 3
d = 0:0.25:3;
h = 1;
C1 = 0.5.*d.^3-(1.5*h.*d.^2)+(1+h.^2).*d;
plot(d,C1)
hold on
h = 1.5;
C2 = 0.5.*d.^3-(1.5*h.*d.^2)+(1+h.^2).*d;
plot(d,C2)
hold on
h = 2;
C3 = 0.5.*d.^3-(1.5*h.*d.^2)+(1+h.^2).*d;
plot(d,C3)
hold on
h = 2.5;
C4 = 0.5.*d.^3-(1.5*h.*d.^2)+(1+h.^2).*d;
plot(d,C4)
hold on
h = 3;
C5 = 0.5.*d.^3-(1.5*h.*d.^2)+(1+h.^2).*d;
plot(d,C5)
xlabel('X');
ylabel('Y');
end
%% Question 1 subfunction
function m = convert(f)
m = f/3.28084;
end
%% Question 2 subfunction
function s = sum(i)
while i<11
s = sum(factorial(i));
end
end
I have tried both running the function by clicking the run button and calling the function by "Spring" in the command window however i get this Error Message: Cannot find an exact (case-sensitive) match for
'Spring'
Please excuse me as my knowledge is limited in this subject
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Symbolic Math Toolbox dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!