Why doesn't this function declaration work?
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!