I am running a model, and I have set 'LoadExternalInput' to 'on' for the simulation. I set my top-level inport's 'Interpolate' option to 'off'. My respective input signal is a constant, so I have it saved as a structure with time, so time is 0, and my signals.values is 1 (or whatever it needs to be, but is nonzero). I notice that for the first time sample, the value is indeed what is expected, but after that goes to zero. Is there anyway to set it so that it hold the last value instead of returning to 0? I'm running 2010a.

 採用された回答

Kaustubha Govind
Kaustubha Govind 2012 年 6 月 21 日

1 投票

I would recommend using the Constant block instead. Importing data via the Inport block requires you to give data in a prescribed format. In your case, the structure needs to contains a time vector and a value vector, where time goes from 0 to the simulation stop time. Specifying the value for t=0 is not sufficient.

5 件のコメント

David
David 2012 年 6 月 21 日
Well there is no gaurantee that the signal will be a constant. I'm running a model for several set's of data, some of which may or may not have constants. When you have a LoadFromWorkspace block, there is an option to hold the last value, which is what I've been using in the past, but I was exploring directly loading from the workspace without the need to add blocks to the model. In those cases, the singal t=0 value was sufficient.
Kaustubha Govind
Kaustubha Govind 2012 年 6 月 22 日
Ah, sorry, I hadn't realize you were using the From Workspace block. I thought you were using the Data Import/Export pane of the Configuration Parameters window.
I just tried what you described, and I do get a Constant value of 1 when the variable using in the From Workspace block is defined as: "in=[0, 1]" with "Interpolate Data" set to "off" and "Form output after final data value by: to "Holding final value".
David
David 2012 年 6 月 22 日
I'm not using the Data Import/Export Pane directly, but I am setting those commands programatically. Is there no analog for inports to "Holding Final Value". I prefer not to clutter up the model with the From Workspace blocks if I can get the same effect just using (effectively) the Data Import/Export. I'm able to import variables directly from the workspace by programtically setting those options equivalent Data Import/Export for the model, but the inports are what are giving me trouble.
And thank you for your help!
Kaustubha Govind
Kaustubha Govind 2012 年 6 月 25 日
AFAIK, there is no equivalent option to "Holding Final Value" (perhaps you could consider asking this as an enhancement via MathWorks Tech Support?), but you could probably turn on 'Interpolate data" on the Inport blocks and construct your import data such that "in=[0 1; StopTime 1]", where StopTime=model simulation stop time.
David
David 2012 年 7 月 9 日
I was hoping to avoid that, but it is ultimately what I ended up doing. Not the most elegant solution, but it'll have to do in the meantime. Thanks.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeEvent Functions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by