필터 지우기
필터 지우기

The transfer function of a small position Sensor

조회 수: 21 (최근 30일)
GHADAH AL-OBAIDI
GHADAH AL-OBAIDI 2021년 9월 28일
댓글: Star Strider 2021년 10월 4일
I have the below matlab code and I would like to find :
  1. 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);
  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;

채택된 답변

Star Strider
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)'
Displacement_d_mm = 1×8
0 0.0800 0.1600 0.2400 0.3200 0.4000 0.4800 0.5200
Force_Nm = [0, 0.578, 1.147, 1.677, 2.187, 2.648, 3.089, 3.295] % Input 'u(t)'
Force_Nm = 1×8
0 0.5780 1.1470 1.6770 2.1870 2.6480 3.0890 3.2950
Ts = 1; % Sampling Interval (Replace With Actual Value)
idd = iddata(Displacement_d_mm(:), Force_Nm(:), Ts)
idd = Time domain data set with 8 samples. Sample time: 1 seconds Outputs Unit (if specified) y1 Inputs Unit (if specified) u1
ff_sys = tfest(idd,1)
ff_sys = From input "u1" to output "y1": 5.26 --------- s + 29.14 Continuous-time identified transfer function. Parameterization: Number of poles: 1 Number of zeros: 0 Number of free coefficients: 2 Use "tfdata", "getpvec", "getcov" for parameters and their uncertainties. Status: Estimated using TFEST on time domain data "idd". Fit to estimation data: 77.7% FPE: 0.00339, MSE: 0.001541
figure
compare(idd, ff_sys)
Experiment to get different results.
.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Model Identification에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by