MATLAB Answers

How can I iteratively create blocks in simulink/simscape and populate them with variables?

5 ビュー (過去 30 日間)
Isaac Friedman
Isaac Friedman 2020 年 1 月 17 日
コメント済み: Fangjun Jiang 2020 年 1 月 17 日
I'm trying to design a program to create multiple "Repeating Sequence Interpolated" blocks as well as "Saturation Dynamic" blocks. The number created, the data used to create the sequences and minima/maxima, and the names of the blocks are all determined in an external .csv or .txt file. The goal is to use the sequences to control the joints of an imported Solidworks assembly. I already know how to import the model and the data, but I'm not sure how to iteratively create the blocks. How can I do this?
%import t, time array
%import m, matrix of data for the joints
%import n, number of sequences needed
%for i:1:n
% create arr, temporary array of position data for column i of m
% create Repeating Sequence Interpolated (RSI) block that references t and arr
% create Saturation Dynamic (SD) block and constant blocks to limit range of signal
% connect constants, RSI, and SD blocks
%end for

  0 件のコメント

サインイン to comment.


Fangjun Jiang
Fangjun Jiang 2020 年 1 月 17 日
What you need are functions like add_block(), add_line(), set_param()
Follow examples in this section of the document "Programmatic Model Editing"

  2 件のコメント

Isaac Friedman
Isaac Friedman 2020 年 1 月 17 日
This is exactly what I was looking for, thank you! Can it also be used to add simscape blocks? I attempted the below code but MATLAB thros an error saying the block doesn't exist.
add_block('simscape/Foundation Library/Utilities/Simulink-PS Converter','DrawbotWithMass/C1');
Fangjun Jiang
Fangjun Jiang 2020 年 1 月 17 日
add_block('nesl_utility/Simulink-PS Converter','DrawbotWithMass/C1')

サインイン to comment.

その他の回答 (0 件)

サインイン してこの質問に回答します。

Translated by