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
wouter grolman 2019 年 11 月 29 日
This is how the plots look like
plot1.jpg
Swastik Sanjay Chaudhury
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
wouter grolman 2019 年 12 月 6 日
I fixed it already, thx for your time
Christopher Bennett
Christopher Bennett 2021 年 4 月 28 日
OP, what was the solution?
Adam Danz
Adam Danz 2021 年 4 月 28 日
My guess is that the use of hold on was freezing the axis limits.

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeInterpolation についてさらに検索

質問済み:

2019 年 11 月 29 日

コメント済み:

2021 年 4 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by