現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
How to solve "Dot indexing is not supported for variables of this type...."?
6 ビュー (過去 30 日間)
古いコメントを表示
Tommy
2025 年 3 月 26 日
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 件のコメント
Walter Roberson
2025 年 3 月 26 日
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
2025 年 3 月 27 日
What happens if
Plus_str = find_system(mdl,'LookUnderMasks','All','FindAll','on','Name','POS');
returns empty because no system named POS was found?
Tommy
2025 年 3 月 27 日
Hi,
But POS is PMC_port stick on canvas...a basic slx flie shown on pic above.....
回答 (1 件)
Walter Roberson
2025 年 3 月 27 日
移動済み: Walter Roberson
2025 年 3 月 27 日
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 件のコメント
Tommy
2025 年 3 月 27 日
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
2025 年 3 月 27 日
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
2025 年 3 月 27 日
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
2025 年 3 月 27 日
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
2025 年 3 月 27 日
編集済み: Tommy
2025 年 3 月 27 日
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
2025 年 3 月 27 日
編集済み: Tommy
2025 年 3 月 27 日
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
2025 年 3 月 27 日
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
2025 年 3 月 27 日
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
2025 年 3 月 27 日
cellfun(@(C)addline(mdl,C.RConn,PH_Add_module{2}.LConn(2), 'Autorouting','on'), PH_Plus2str, 'uniform', 0);
Tommy
2025 年 3 月 27 日
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
2025 年 3 月 27 日
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
2025 年 3 月 27 日
"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
2025 年 3 月 27 日
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'
参考
カテゴリ
Help Center および File Exchange で Programmatic Model Editing についてさらに検索
タグ
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- 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)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)

