How to read in big parts of text to my code

1 回表示 (過去 30 日間)
Malin Dyberg
Malin Dyberg 2018 年 12 月 17 日
回答済み: Akshay Khadse 2018 年 12 月 28 日
What I want to do is to ask the user to write in the text that they want to decrypt. Not only a single sentence but big parts of text with multiple rows, commas, indentations and so on (for example a letter). How do I do this? I've tried using input but that only works for short sentences.
  5 件のコメント
Rik
Rik 2018 年 12 月 17 日
If you insist of using Matlab tools, you could use the edit type uicontrol (enable multi-line by setting the max property to the maximum number of lines you allow your user to type).
Malin Dyberg
Malin Dyberg 2018 年 12 月 17 日
Ok thanks. I'll figure something out :)

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

回答 (1 件)

Akshay Khadse
Akshay Khadse 2018 年 12 月 28 日
This could easliy be done by writing a function to use dialog with an edit uicontrol in MATLAB based on the following example:https://www.mathworks.com/help/matlab/ref/dialog.html#bungryc-2_1
I happen to use the following function for such tasks:
function out = textIn
close all; clear; clc
f = dialog('Position', [1000 1000 320 150],...
'MenuBar', 'none',...
'Name','Enter Text',...
'NumberTitle','off');
uicontrol('Parent',f,...
'Style','edit',...
'Max',2,...
'Min',0,...
'Position', [10 42 300 100],...
'HorizontalAlignment','left',...
'Callback', @editCallback);
uicontrol('Parent',f,...
'Style','pushbutton',...
'String','OK',...
'Position', [235 10 75 25],...
'Callback', "delete(gcf)");
uiwait(f);
function editCallback(h,~)
out = h.String;
end
end

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by