The transfer function of a small position Sensor
조회 수: 21 (최근 30일)
이전 댓글 표시
I have the below matlab code and I would like to find :
- First Order Fit: try (polyfit), Find the Matlab function for fitting: P = WHAT_FUNCTION(WHAT TO FIT as what is x, WHAT TO FIT as what is y, ORDER); Force_Nm_Linear = P(1) * Displacement_d_mm + P(2);
- Second Order Fit, same as above: what is x, y, ORDER P = WHAT_FUNCTION(WHAT TO FIT, WHAT TO FIT, ORDER); Force_Nm_2nd_Order = P(3) + P(2)*Displacement_d_mm + P(1)*Displacement_d_mm.*Displacement_d_mm;
Note: we have to set some of the coefficients to = 0 to check if it can be ignored:
P(3) = 0;
Force_Nm_2nd_two_Terms = P(3) + P(2)*Displacement_d_mm + P(1)*Displacement_d_mm.*Displacement_d_mm;
My Matlab code is::::::::::::::::
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all;
close all;
clc;
Displacement_d_mm = [0, 0.08, 0.16, 0.24, 0.32, 0.4, 0.48, 0.52];
Force_Nm = [0, 0.578, 1.147, 1.677, 2.187, 2.648, 3.089, 3.295];
% Part A: First Order Fit:
% In this case, x is the displacement and y is the force.
% where d is the displacement and F the force
P = polyfit(Displacement_d_mm, Force_Nm, 1);
Force_Nm_Linear = P(1) * Displacement_d_mm + P(2); % F = 6.3221d + 0.089
% Part B:
Displacement_d_mm_b = [0, 0.32, 0.52];
Force_Nm_b = [0, 2.187, 3.295];
% Second Order Fit:
P = polyfit(Displacement_d_mm, Force_Nm, 2);
Force_Nm_2nd_Order = P(3) + P(2)*Displacement_d_mm + P(1)*Displacement_d_mm.*Displacement_d_mm;
댓글 수: 0
채택된 답변
Star Strider
2021년 9월 28일
If you actually want the transfer function, use the System Identification Toolbox functions —
Displacement_d_mm = [0, 0.08, 0.16, 0.24, 0.32, 0.4, 0.48, 0.52] % Output 'y(t)'
Force_Nm = [0, 0.578, 1.147, 1.677, 2.187, 2.648, 3.089, 3.295] % Input 'u(t)'
Ts = 1; % Sampling Interval (Replace With Actual Value)
idd = iddata(Displacement_d_mm(:), Force_Nm(:), Ts)
ff_sys = tfest(idd,1)
figure
compare(idd, ff_sys)
Experiment to get different results.
.
댓글 수: 2
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Linear Model Identification에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!