- #1
roam
- 1,271
- 12
The following is part of an experiment about the speed of sound in different depths of a liquid, I'm trying to solve it in Matlab.
http://img546.imageshack.us/img546/5952/20120408201206.jpg
Here is my attempt:
But I keep getting the following error:
What is wrong with my code, and how can I fix it? Any help is greatly appreciated.
http://img546.imageshack.us/img546/5952/20120408201206.jpg
Here is my attempt:
Code:
clc
clf
N=13;
d=1900:-100:700;
t=[2.62 2.37 2.35 2.25 2.09 1.86 1.78 1.64 1.53 1.35 1.18 1.09 0.89];
plot(d,t, '-m*');
p = polyfit(d,t,1);
hold on
plot(d,polyval(p,d))
tf=polyval(p,d);
for i = 1:1:N
sigmat=sqrt(sum(((t-tf).^2)/(N-2)));
end
[p,sp]=regress(d,t,sigmat,1)
But I keep getting the following error:
Code:
Error using regress
Too many input arguments.
Error in Q2 (line 24)
[p,sp]=regress(d,t,sigmat,1)
What is wrong with my code, and how can I fix it? Any help is greatly appreciated.
Last edited by a moderator: