How can I have the To File block use the file name from a workspace variable in Simulink 6.5 (R2006b)?
조회 수: 2 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2009년 6월 27일
댓글: Kaustubha Govind
2014년 3월 18일
I have a To File block in my model and I want to use a workspace variable containing a string to specify the file name for this block. The To File block does not accept the name of a workspace variable like the Gain block does.
채택된 답변
MathWorks Support Team
2009년 6월 27일
The To File block does not have the ability to evaluate a workspace variable to get the file name. In this case you can mask the block and call the SET_PARAM function from the mask's initialization callback function. Here are the steps:
1. Select the To File block in your model
2. In the Command Window enter
set_param(gcb,'Mask','on');
3. Right-click the block and choose "Edit mask" from the context menu.
4. On the Parameters pane in the Mask Editor add a parameter to store the file name entered by the user
5. On the Initialization pane add a call to SET_PARAM to set the To File block's filename property:
set_param(gcb,'Filename',fn);
6. You can now enter the filename as string into the block mask or you can enter the name of a variable which is then evaluated
Please find attached an example model. The steps mentioned above could also be used for the following blocks:
- To Workspace
- From Workspace
- To File
- From File
댓글 수: 1
Kaustubha Govind
2014년 3월 18일
Jeff: What is the value that you enter for the 'fn' parameter on the mask dialog?
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!