Column vector consisting of n words containing random numbers
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Marcel Król
am 6 Jun. 2020
Kommentiert: Image Analyst
am 7 Jun. 2020
I am working for Matlab for the first time, so can you please solve this task step by step? task: Create a column vector A consisting of n words containing random numbers. Then create a column vector B in which the words from the vector A are sorted in ascending order. Show results in the chart.
Please help
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 6 Jun. 2020
Did you try randi(), randperm(), sort(), or strsplit()? Because it's pretty easy:
txt = 'Create a column vector A consisting of n words containing random numbers. Then create a column vector B in which the words from the vector A are sorted in ascending order. Show results in the chart.'
words = strsplit(txt)
n = 5
% Choose the rule for the random numbers:
r = randi(length(words), n, 1) % Can possibly repeat
r = randperm(length(words), n) % No repeats
A = words(r)'
B = sort(A)
8 Kommentare
Image Analyst
am 7 Jun. 2020
I'd probably just loop and use fprintf() to print them out. Unless you think it wants a uitable control, like a spreadsheet.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!