필터 지우기
필터 지우기

Multiple formulas in one function?

조회 수: 4 (최근 30일)
gblmtc
gblmtc 2018년 3월 31일
댓글: gblmtc 2018년 4월 1일
Hi there!
I have attached 2 pics. There are 7 formulas, the second formula uses the output from the first formula, the third formula uses the output from the second one and so on.
My question is: could I put all these formula in just one function?
I’ve tried creating a function for each formula and after that to include all of them in one big function but it’s not working :(. I don’t know how to call the big function.
Maybe is there somebody and could give me hint for this.
Thank you!

채택된 답변

Image Analyst
Image Analyst 2018년 3월 31일
Sure, just compute and return the numerical results
function [n,mu,M,lambda, etc] = Compute7Formulas(inputs)
n = ......whatever
M = ...... whatever....
lambda = whatever
% etc.
  댓글 수: 7
Image Analyst
Image Analyst 2018년 4월 1일
Make a separate m-file called test.m. In it, have these lines of code
t=3; % Define an input.
toe=5; % Define another input.
%etc. % Define even more inputs.
[n, mu, M, lambda, etc] = Compute7Formulas(t, toe, etc)
where you replace etc with all the other various variables you need. Then you can have the cursor in test.m (NOT in Compute7Formulas.m) and click the green run arrow or type F5.
gblmtc
gblmtc 2018년 4월 1일
Thank you!
I will try that!

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by