Fit curve in a subplot
显示 更早的评论
I have a problem, if i want to fit a sin function over my data in different subplots. The sinefunction only plots one period.
If I plot the fuction without a subplot (in its own figure), the fit does work perfectly as shown.
Can sombody help me with a solution?
%% Basic approach for calibration of force sensors etc., Peter Poot
clear all
close all
clc
[rn1 rn2 rn3 n11 n12 n13 B]=dataverwerken_stijn1(2.25,0);
n2=6000;
for n=1:3
for m=2:54
B(:,m,n)= B(:,m,n)-mean(B(:,m,n));
end
end
%% test
% test the hack out of it
T1 = [n11 n12 n13];
figure
for n=1:1
for i=[5] %,10,17] %,24,28,32,36,40,44,48,52]
A=fit(B(T1(n):n2,1,n),B(T1(n):n2,i,n),'sin1')
subplot(3,1,n)
plot(A)
hold on
plot(B(T1(n):n2,1,n),B(T1(n):n2,i,n))
xlim([0 60])
end
end
figure
A=fit(B(T1(1):n2,1,1),B(T1(1):n2,5,1),'sin1')
plot(A)
hold on
plot(B(T1(n):n2,1,n),B(T1(n):n2,i,n))
xlim([0 60])
5 个评论
wouter grolman
2019-11-29
Swastik Sanjay Chaudhury
2019-12-5
Hello wouter,
When I tried reproducing the issue on my end, I ran into the error :
"Undefined function or variable 'dataverwerken_stijn1'.
Error in Untitled5 (line 6)
[rn1 rn2 rn3 n11 n12 n13 B]=dataverwerken_stijn1(2.25,0);"
Looks like 'dataverwerken_stijn1' is a user defined function. It would help if you could provide the functon code for the same.
wouter grolman
2019-12-6
Christopher Bennett
2021-4-28
OP, what was the solution?
Adam Danz
2021-4-28
My guess is that the use of hold on was freezing the axis limits.
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
