Can I access what's in the test vector in MatLab code during Main Test?

1 次查看(过去 30 天)
I saw a matlab page that talked about a getValue method, but I get an error saying "Attempt to reference field of non-structure array".
I don't think I understand what TestVector is, so that I can access its contents. The help really focuses on how to create them using the wizard.
Thanks
  1 个评论
James
James 2011-8-26
What I've sometimes done is created an input and signal straight to an output simply for a signal that's in the Test Vector (such as expected output), so that I can use it in a check as is appropriate. It's the easiest access I've normally found to it.

请先登录,再进行评论。

采纳的回答

Bart Addis
Bart Addis 2011-8-29
If you create a MATLAB element in the Main Test, you'll be able to access the test vector directly by name. It will contain the value for the current iteration.
If you create a test vector T with values [1:1:10], then in iteration 3, T will have the value 3.
  3 个评论
Bart Addis
Bart Addis 2011-8-29
Are you using the Excel Test Vector to create these, or are you using xlsread?
James
James 2011-8-29
The former, the wizard claims it evaluates to a 1x1 cell but I've realised - for example - TestVector1(1,3) does give access to the third element on the first row.

请先登录,再进行评论。

更多回答(1 个)

Fangjun Jiang
Fangjun Jiang 2011-8-26
Is your test vector data a structure? The function to get its field is called getfield(). getvalue() seems to be a different function.
  12 个评论
Fangjun Jiang
Fangjun Jiang 2011-8-29
Your TestVector1 is an ordinary 2-D double array. To access it, just type TestVector1 in Command Window and you'll see the value. To access individual element, use TestVector1(3,2) for example.
James
James 2011-8-29
If you want to access SystemTest variables from the Command Window you need to use:
stresults.ResultsDataSet; // used after a test
// or
obj = systest.testresults.getCurrent;
currentResults = obj.ResultsDataSet; // used during a test
If you hadn't realised, I'm not trying to access it in the Command Window - but in a SystemTest Matlab code element.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Test Model Components 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by