Populate pyargs() arguments with the contents of a string cell array.

2 ビュー (過去 30 日間)
Ajpaezm
Ajpaezm 2018 年 5 月 22 日
編集済み: Stephen23 2018 年 5 月 22 日
Hello everybody,
I'd like to know if there's a way to populate the arguments of pyargs() with the contents of an array, instead of hardcoding the values like the documents tell us.
I have this simple function I'm using for testing:
function s=my_test(varargin)
extraParams=cell(numel(varargin),2);
for i=1:numel(varargin)
str = varargin{i};
C = strsplit(str,'=');
extraParams{i,1}=C{1};
extraParams{i,2}=C{2};
end
s=extraParams;
end
If I use these inputs:
a=my_test('k1=v1','k2=v2','k3=v3')
I get:
a=
'k1' 'v1'
'k2' 'v2'
'k3' 'v3'
How can I pass these values to pyargs() like this?
pyargs('k1','v1','k2','v2','k3','v3')?
Thankful for any help you could bring :)

回答 (2 件)

Walter Roberson
Walter Roberson 2018 年 5 月 22 日
a = my_test(TheCellArray{:})
  2 件のコメント
Ajpaezm
Ajpaezm 2018 年 5 月 22 日
Ahm... my_test is the function that generates the cell array. I want to populate pyargs() with the contents of that cell array.
Walter Roberson
Walter Roberson 2018 年 5 月 22 日
pyargs(a{:})

サインインしてコメントする。


Stephen23
Stephen23 2018 年 5 月 22 日
編集済み: Stephen23 2018 年 5 月 22 日
tmp = a.';
pyargs(tmp{:})

カテゴリ

Help Center および File ExchangeCall Python from MATLAB についてさらに検索

タグ

製品


リリース

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by