Sinulink S-function block blank parameter error-MATLAB2011b

Hello,
I am using a user defined S-function Simulink block. I have two parameters inside it: 'DesignName' and 'DesignPath'. Both parameters are blank at the start of the application.
At some point I try to use "set_param" to set values to these parameters. I receive the following error:
" Parameter 'DesignName' setting: "" cannot be evaluated. Error: This statement is incomplete."
However, although I receive this error the correct value is still set.
The error causes my application not to work. When I run the same code on 2011a I do not receive this error and my application completes successfully.
I see the same phenomena when I try to set these parameters with the values manually, using the Simulink GUI.
Are you familiar with such a problem?
Thank you in advance,
Gilad

2 Comments

Could you show us the exact set_param statement that you use to set the parameter? Typically, set_param causes the value to be set on the block even if there is an error (although simulation will not proceed because of the error).
Thank you for your answer.
As I wrote I see that the value is set, but the error causes my application not to work, as it it wrapped inside a try and catch statement. I don't this the command is relevant as I see the same error when I try to change the values using the Simulink GUI. In addition, the same code works in 2011a. However, since you have asked for the line, here it is:
set_param([modelName '/' modelName '_HW_block'], 'DesignName', ['''' modelName '''']);

Sign in to comment.

Answers (1)

Could you try changing that to:
set_param([modelName '/' modelName '_HW_block'], 'DesignName', modelName);
You shouldn't need to put single quotes around a variable that is already a string. You only need that if you're doing something like:
set_param([modelName '/' modelName '_HW_block'], 'DesignName', 'mymodel');
It is possible that SET_PARAM was made more robust to the extra apostrophes in R2011a.

9 Comments

Thank you for your answer.
I have tried it but it still does not work.
Strange - can you reproduce this outside of your application? That is, open the corresponding model, and perform the set_param command? What is the value of modelName?
Yes, I can. When I open the "S-Function" block I see that both parameters are empty. When I try to set a value to one of them I see the same error:
" Parameter 'DesignName' setting: "" cannot be evaluated. Error: This statement is incomplete."
Do you mean that you're setting the value of the "S-function parameters" dialog box? I don't think the S-function block has a parameter called DesignName.
"DesignName" is a field that was added to the block by my application.
Maybe "S-Function" this is not the name of the block. The name I see when I open it is:
"S-Function (mask)". Maybe it is a user-defined block (I do not have the correct information as I did not create it nor am I not the programmer of the application). I will try to find the exact name of the block and write it down here.
The thing is that when I do it with MATLAB 2011a it works well- I only receive this error with MATALB2011b
So, just to be clear, you do something like:
set_param('path/to/S-Function', 'DesignName', 'somevalue')
Is this correct?
Yes, you are correct, this is what I do. I was advised by my local distributor to set a dfault value to the block. I will try it. I still think that there is a small change between the newest version and the previous one, but it does not seem to be important should this workaround work.
Thank you for your efforts,
Gilad
Okay, great! Hopefully your distributor's advice will help. I'm thinking that I don't see the full picture because of how the mask on your S-function is handling the value - there might be some callback code on the mask that is run every time a set_param is performed.
I think you don't see the full picture because I myself do not fully understand this block. Anyway, the default suggestion solved our issue: now MATALB 2011b does not produce the error.
Thank you very much for all your efforts and time spent.
Gilad

Sign in to comment.

Categories

Find more on Modeling in Help Center and File Exchange

Asked:

on 9 Nov 2011

Community Treasure Hunt

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

Start Hunting!