MATLAB: How to model a time varying finction from text file…..

simulinktext filetime varying function

I had a data from a gyroscope sensor in the form of a text file. The data represents the XYZ relative displacements. I need to create a road excitation function so that i can simulate my suspension system in simulink. Please any one tell me how i can create a function which relate the data with time.

Best Answer

Okay, you must know the sample time of your data in the text file. Let's assume your sample time is 0.1 second. Your data in the text file contains a 100x3 matrix, representing the x, y and z displacement from 0 to 10 seconds.
First, import your text data into workspace use importdata(), uiimport() or textscan. Once you have the data, for example, x=rand(100,1), you need to create a time vector t=(0:0.1:9.9)', the reason for 9.9 is because it starts at 0 so the vector t also has exactly 100 samples of data.
Then drag a "From Workspace" block, double click, put in [t,x] for 'data' in the dialog window. You've got the time varying signal for x.