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에서 Interpolation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
