When I try to run this command,
myArray = zeros(constantVar, 1);
I get the following error:
Non-constant expression or empty matrix. This expression must be constant because its value determines the size or class of some expression
What I am confused about is that in the Simulink model, the inport of the EMF block has a constant block.
However, if I run the command,
for i = 1:length(arrayVar)
...some code...
end
It works fine. I would have thought I'd get the same error. I assume for loops have different requirements than the zeros function.
Is there something I'm missing here to have the zeros function work with an argument?
The way to do what you want is with a non-tunable parameter, not with a
signal. Get rid of the constant block. Then bring up the Model Explorer.
Find the Embedded MATLAB block in the model hierarchy on the left. Click on
it, and then click on the input argument that you need to be a constant in
the middle pane (or right click on it and select "Properties" to bring up
the properties dialog). Then over in the right pane (if you left-clicked)
or properties dialog (if you right-clicked), change the "Scope" from "Input"
to "Parameter" and uncheck the "Tunable" box that appears after you change
the scope. Apply those changes. Now define the named variable in your
MATLAB workspace to have the constant value you want. Rebuild and run the
simulation. Now you should be able to change this value, rebuild, and run
the simulation without changing the model.
--
Mike
"Thomas Marullo" <tm...@lehigh.edu> wrote in message
news:gie2tg$kg8$1...@fred.mathworks.com...