Why doesn't this function declaration work?
이전 댓글 표시
I'm sorry that this is an extremely basic question that people might get irritated by, but I am new and I am trying to do some scripting. I want to declare a function that makes an array for concentration values of a serial dilution. As far as I can tell, I am following the syntax matlab gives for function EXACTLY, but it still gives an error when i call the function with what should be valid parameters.
For example, this should return a 24 by 1 array that is [ 25, 15, 9, ... ]
input:
a = serialdilution(25, 1.6666, 24)
output:
Error: File: serialdilution.m Line: 1 Column: 28
with this function definition in the \MATLAB path named serialdilution.m
function concentrations = serialdilution(maxconc, factor, n)
%returns an n by 1 array whose last element is maxconc
%and each previous value is equal to the next element divided
%by factor
for i=1:n
concentrations(n-i-1) = maxconc*(1/factor^(i-1);
end
concentrations = concentrations.';
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!