The problems you are having has nothing to do with the type of block being used, it has to do with the way you are creating the mask.
There are several syntax/usage problems with your above code.
1. within the initialization pane you already have access to all variables defined on the mask's Parameters tab, you do not need to use
Post by J Avals = get_param(gcb,'MaskValues');
The parameters are listed on the left hand side of the Initialization tab for convenience.
2. It's not really clear what you are trying to achieve with
Post by J AportStr = {'port_label(''output'',1,'num2str(channel(1)) '))'};
for i=1:length(channel)
portStr= {'port_label(''output'','num2str(i),num2str(channel(i) '));'};
end
Nowhere here would port_label get executed.
It's almost as if you are trying to form a string that would then be executed by the eval function.
3.
Post by J APost by J Aset_param(gcb,'MaskDisplay',char(portStr));
is not the way to set the mask display, that should be done on the mask's Icon tab.
This is what you need to do:
I'm going to assume that you are creating a mask for a block that has 3 inputs.
On the Initialization tab you want to create the strings that you want to use to label your inports/outports.
So something like the following lines
labels = cell(1,3);
for idx = 1:3
labels{idx} = sprintf('channel %d',idx);
end
Then on the Icon tab you want
port_label('input',1,labels{1})
port_label('input',2,labels{2})
port_label('input',3,labels{3})
Note that you cannot use a loop on the icon tab, you need to write each line explicitly.
You'll need to modify my example slightly to fit the number of inputs that you have, and probably do something similar for outputs.
Phil.