MATLAB Answers

How to read in big parts of text to my code

1 view (last 30 days)
Malin Dyberg
Malin Dyberg on 17 Dec 2018
Answered: Akshay Khadse on 28 Dec 2018
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.


Show 2 older comments
Jan on 17 Dec 2018
If you want the users to type in a large text, let them do this in an editor. E.g. Matlab's built-in editor or an external one. Re-inventing the wheel by creating an editor in a Matlab-GUI is off track.
Rik on 17 Dec 2018
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 on 17 Dec 2018
Ok thanks. I'll figure something out :)

Sign in to comment.

Answers (1)

Akshay Khadse
Akshay Khadse on 28 Dec 2018
This could easliy be done by writing a function to use dialog with an edit uicontrol in MATLAB based on the following example:
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',...
'Position', [10 42 300 100],...
'Callback', @editCallback);
'Position', [235 10 75 25],...
'Callback', "delete(gcf)");
function editCallback(h,~)
out = h.String;


Sign in to comment.

Community Treasure Hunt

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

Start Hunting!