Fit curve in a subplot
Show older comments
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 Comments
wouter grolman
on 29 Nov 2019
Swastik Sanjay Chaudhury
on 5 Dec 2019
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
on 6 Dec 2019
Christopher Bennett
on 28 Apr 2021
OP, what was the solution?
Adam Danz
on 28 Apr 2021
My guess is that the use of hold on was freezing the axis limits.
Answers (0)
Categories
Find more on Interpolation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!