You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
How to solve "Dot indexing is not supported for variables of this type...."?
6 views (last 30 days)
Show older comments
Tommy
on 26 Mar 2025
Hi,
I wrote a small script to made 4 modules and connection betweeen (pic attached).
I got error message while I tried to connect phisical POS and got "Dot indexing not support for variableof this type".
Can someone help tounderstand whats the problem?
file Matlab script:
open_system('String_arc')
mdl = 'String_arc';
Cube_model = find_system(mdl,'FindAll','on','Name','String_arc');
%%% add basic Module:
for v=1:4 %% loop for 4 Modules
nl=num2str(v);
Add_module(v) = add_block('Mod_26_cells/Module_MC 1', [mdl,'/Module_MC ',nl]);
posc = get(Add_module(v),'Position');
set(Add_module(v),'Position',posc + [100 120*(v-1)-45 100 120*(v-1)-45])
PH_Add_module{v}=get(Add_module(v),'PortHandles');
%%% connect minus to plus ports:
if v>1
add_line(mdl,PH_Add_module{v-1}.LConn(2),PH_Add_module{v}.LConn(1),'Autorouting','on');
end
end
% connect the POS port to first CELL (Cell 1):
Plus_str = find_system(mdl,'LookUnderMasks','All','FindAll','on','Name','POS');
PH_plus2str=get(Plus_str,'PortHandles');
add_line(mdl,Plus_str.RConn,PH_Add_module{1}.LConn(1), 'Autorouting','on');

4 Comments
Walter Roberson
on 26 Mar 2025
Is the error showing up on the line
add_line(mdl,PH_Add_module{v-1}.LConn(2),PH_Add_module{v}.LConn(1),'Autorouting','on');
or is the error showing up on the line
add_line(mdl,Plus_str.RConn,PH_Add_module{1}.LConn(1), 'Autorouting','on');
Walter Roberson
on 27 Mar 2025
What happens if
Plus_str = find_system(mdl,'LookUnderMasks','All','FindAll','on','Name','POS');
returns empty because no system named POS was found?
Tommy
on 27 Mar 2025
Hi,
But POS is PMC_port stick on canvas...a basic slx flie shown on pic above.....
Answers (1)
Walter Roberson
on 27 Mar 2025
Moved: Walter Roberson
on 27 Mar 2025
What happens if the command returns empty because no matching lines, ports, or annotations were found?
Option to search for a specific type of model element, specified as one of these:
- 'block'
- 'line'
- 'port'
- 'annotation'
To find lines, ports, or annotations in the model, you must first specify the value of FindAll as 'on', and then the value of Type.
You did not specify 'type' in your search, so no searching by port would be done.
20 Comments
Tommy
on 27 Mar 2025
Hi,
I don't get your point.
what you mentioned, allready written:
Plus_str = find_system(mdl,'LookUnderMasks','All','FindAll','on','Name','POS');
.....
Walter Roberson
on 27 Mar 2025
Plus_str = find_system(mdl, 'LookUnderMasks', 'All', 'FindAll', 'on', 'Type', 'port', 'Name', 'POS');
It is specifically documented that in order to search by port that you have to 'type', 'port' and also specify FindAll
Tommy
on 27 Mar 2025
Hi,
wow, Still got same error:
Plus_str = find_system(mdl, 'LookUnderMasks', 'All', 'FindAll', 'on', 'Type', 'port', 'Name', 'POS');
PH_plus2str=get(Plus_str,'PortHandles');
add_line(mdl,PH_plus2str.RConn,PH_Add_module{2}.LConn(1), 'Autorouting','on');
ot indexing is not supported for variables of this type.
Error in String_Array (line 33)
add_line(mdl,PH_plus2str.RConn,PH_Add_module{2}.LConn(1), 'Autorouting','on');
Steven Lord
on 27 Mar 2025
Add these commands immediately before the add_line call and show us exactly what gets returned by each of the commands.
PH_plus2str
PH_Add_module{2}
If PH_plus2str is empty, show us the output of this command as well:
Plus_str
If that too shows an empty array, let's try finding all the ports in your system and see what their Name properties are. I'm leaving the semicolon off deliberately as I want to see what and how many ports find_system finds.
Plus_str = find_system(mdl, 'LookUnderMasks', 'All', 'FindAll', 'on', 'Type', 'port')
Tommy
on 27 Mar 2025
Edited: Tommy
on 27 Mar 2025
Hi,
Just added as you recomended:
Plus_str = find_system(mdl, 'LookUnderMasks', 'All', 'FindAll', 'on', 'Name', 'POS')
PH_Plus2str=get(Plus_str,'PortHandles');
PH_plus2str
PH_Add_module{2}
add_line(mdl,PH_plus2str.RConn,PH_Add_module{2}.LConn(2), 'Autorouting','on');
results:
>> String_Array
Plus_str =
1.0e+03 *
0.6820
4.1509
0.0030
Unrecognized function or variable 'PH_plus2str'.
Error in String_Array (line 36)
PH_plus2str
Tommy
on 27 Mar 2025
Edited: Tommy
on 27 Mar 2025
Hi,
Please, see result below:
>> String_Array
Plus_str =
1.0e+03 *
0.6820
4.6621
0.0030
PH_Plus2str =
3×1 cell array
{1×1 struct}
{1×1 struct}
{1×1 struct}
ans =
struct with fields:
Inport: []
Outport: 4.7481e+03
Enable: []
Trigger: []
State: []
LConn: [1.2490e+04 4.7491e+03]
RConn: []
Ifaction: []
Reset: []
Dot indexing is not supported for variables of this type.
Error in String_Array (line 44)
add_line(mdl,PH_Plus2str.RConn,PH_Add_module{2}.LConn(2), 'Autorouting','on');
>>
Tommy
on 27 Mar 2025
Plus_str = find_system(mdl, 'LookUnderMasks', 'All', 'FindAll', 'on', 'Name', 'POS')
PH_Plus2str=get(Plus_str,'PortHandles');
for i = 1:3
PH_Plus2str{i}
end
% PH_Plus2str
PH_Add_module{2}
add_line(mdl,PH_Plus2str.RConn,PH_Add_module{2}.LConn(2), 'Autorouting','on');
>> String_Array
Plus_str =
1.0e+03 *
0.6820
4.6622
0.0030
ans =
struct with fields:
Inport: []
Outport: []
Enable: []
Trigger: []
State: []
LConn: []
RConn: 1.2492e+04
Ifaction: []
Reset: []
ans =
struct with fields:
Inport: []
Outport: []
Enable: []
Trigger: []
State: []
LConn: []
RConn: 1.2493e+04
Ifaction: []
Reset: []
ans =
struct with fields:
Inport: []
Outport: []
Enable: []
Trigger: []
State: []
LConn: []
RConn: 5.0310
Ifaction: []
Reset: []
ans =
struct with fields:
Inport: []
Outport: 4.7482e+03
Enable: []
Trigger: []
State: []
LConn: [1.2490e+04 4.7492e+03]
RConn: []
Ifaction: []
Reset: []
Dot indexing is not supported for variables of this type.
Error in String_Array (line 49)
add_line(mdl,PH_Plus2str.RConn,PH_Add_module{2}.LConn(2), 'Autorouting','on');
Torsten
on 27 Mar 2025
So you see that
add_line(mdl,PH_Plus2str{i}.RConn,PH_Add_module{2}.LConn(2), 'Autorouting','on');
should work if you set i to 1, 2 or 3.
Walter Roberson
on 27 Mar 2025
cellfun(@(C)addline(mdl,C.RConn,PH_Add_module{2}.LConn(2), 'Autorouting','on'), PH_Plus2str, 'uniform', 0);
Tommy
on 27 Mar 2025
cellfun(@(C)add_line(mdl,C.RConn,PH_Add_module{2}.LConn(2), 'Autorouting','on'), PH_Plus2str, 'uniform', 0);
Error using String_Array>@(C)add_line(mdl,C.RConn,PH_Add_module{2}.LConn(2),'Autorouting','on') (line 50)
The port handle does not belong to any object within the system 'String_arc'
Error in String_Array (line 50)
cellfun(@(C)add_line(mdl,C.RConn,PH_Add_module{2}.LConn(2), 'Autorouting','on'), PH_Plus2str, 'uniform', 0); - Show complete stack trace
Walter Roberson
on 27 Mar 2025
cellfun -- apply a function to each element of a cell.
So we are taking the cell array PH_Plus2str and for each member of the cell array we are applying the anonymous function
@(C)addline(mdl,C.RConn,PH_Add_module{2}.LConn(2), 'Autorouting','on')
The anonymous function accepts the contents of one cell at a time, and applies the function
addline(mdl,C.RConn,PH_Add_module{2}.LConn(2), 'Autorouting','on')
to the contents, with C replaced by the contents of the cell entry.
Another way of expressing this would have been
for i = 1 : numel(PH_Plus2str)
addline(mdl,PH_Plus2str{i}.RConn,PH_Add_module{2}.LConn(2), 'Autorouting','on');
end
Torsten
on 27 Mar 2025
"C" in the command
addline(mdl,C.RConn,PH_Add_module{2}.LConn(2), 'Autorouting','on')
is substituted by PH_Plus2str{1},PH_Plus2str{2},PH_Plus2str{3} one after the other.
Output of
cellfun(@(C)addline(mdl,C.RConn,PH_Add_module{2}.LConn(2), 'Autorouting','on'), PH_Plus2str, 'uniform', 0);
is a cell array with elements
{addline(mdl,PH_Plus2str{1}.RConn,PH_Add_module{2}.LConn(2), 'Autorouting','on'),addline(mdl,PH_Plus2str{2}.RConn,PH_Add_module{2}.LConn(2), 'Autorouting','on'),addline(mdl,PH_Plus2str{3}.RConn,PH_Add_module{2}.LConn(2), 'Autorouting','on')}
Tommy
on 27 Mar 2025
After adding last line....
>> String_Array
Plus_str =
1.0e+03 *
0.6820
4.6623
0.0030
Error using String_Array (line 51)
The port handle does not belong to any object within the system 'String_arc'
See Also
Categories
Find more on Programmatic Model Editing in Help Center and File Exchange
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
