How to display a vector in edit text in MATLAB?

12 ビュー (過去 30 日間)
Demeter Andreea
Demeter Andreea 2019 年 8 月 10 日
コメント済み: Adam Danz 2019 年 8 月 10 日
Hello, I need to display a vector in edit text and I don't know how to do that, please, a little help if someone can...
This is my code:
From interface:
uicontrol('Style','Text',...
'Units','Normalized',...
'Position',[0.085,0.68,0.1,0.03],...
'BackgroundColor',[0.75,0.75,0.75],...
'FontSize',10,...
'FontWeight','b',...
'String','Vi[Vector intrare]:');
uicontrol('Style','Edit',...
'Units','Normalized',...
'Position',[0.09,0.63,0.05,0.03],...
'FontSize',10,...
'String',Vi,...
'Callback','Vi=str2num(get(gco,''String''));interfata(R,L,C,tip,Ver,Vi)');
In the main program:
Vi=[0 0 1 0 0 1 1 0 0 0 0 0];
interf(N,R,tip,Ver,Vi);

採用された回答

Adam Danz
Adam Danz 2019 年 8 月 10 日
編集済み: Adam Danz 2019 年 8 月 10 日
Vi=[0 0 1 0 0 1 1 0 0 0 0 0];
>> s = ['Vi[',regexprep(num2str(Vi),' +',' '),']']
s =
'Vi[0 0 1 0 0 1 1 0 0 0 0 0]'
  8 件のコメント
Demeter Andreea
Demeter Andreea 2019 年 8 月 10 日
Thank u for everything! U helped me a lot. :)
Adam Danz
Adam Danz 2019 年 8 月 10 日
Cu plăcere!

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

その他の回答 (1 件)

dpb
dpb 2019 年 8 月 10 日
By default it appears the Edit control converts an array to a column array of values and you can't display that in one row...if the size isn't too long and you can afford the real estate on the screen, you could set the 'min/max' properties and display the rows.
To keep as a one-row string, you've got to do the text conversion yourself --
vstr=sprintf([repmat('%d,',1,numel(Vi)-1) '%d'],Vi);
hUIEd=uicontrol('Syle','Edit', ...
...
'String',vstr,
...);
and use it as the 'String'
  1 件のコメント
Demeter Andreea
Demeter Andreea 2019 年 8 月 10 日
Thanks for your sugestions. I solved the problem.

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

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by