Variable sample time with different time values
古いコメントを表示
Hello,
i have the following data,for example and a simulation duration in simulink for 2 seconds.
Time Parameter
0 4
0.7 8
1.14 10
2 7
With a From Workspace Block i transfer the time and parameter data to simulink. With a To Workspace Block i transfer the results to matlab workspace.
Which setting do i have to change in simulink or how do i set the sample time in the To Workspace Block
that i got four results for 0,0.7,1.14 and 2 seconds to the matlab workspace?
Regards,
Philipp
4 件のコメント
Mathieu NOE
2021 年 1 月 11 日
hello
you mean 5 results for 0,0.7,1.14 and 2 seconds ?
you can use in matlab interp1 to gerate the missing 5th value for parameter
Philipp Vogel
2021 年 1 月 11 日
Mathieu NOE
2021 年 1 月 12 日
hello
my first idea would be to make the simulink (fixed) steps = 0.02 (because then you can "pick" the data with time index whatever time value as soon as they are multiples of 0.02 , which is the case for the time values you are looking for)
simulink time simulation must be set from 0 to 2 s.
of course the array generated by simulink will have more values than needed , but you simply have to add in your script that you want only those values : see example below (tested with dummy data - to be replaced by your simulink array)
time = 0:0.02:2; % dummy data
data = (1:length(time))*5; % dummy data
tt = [0,0.7,1.14,2]; % time values for data retrieval
idx = ismembertol(time(:), tt(:));
c = 1:length(time);
d = c(idx) % searched time indexes
extracted_data = data(d)
Philipp Vogel
2021 年 1 月 14 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Sources についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
