필터 지우기
필터 지우기

manipulatng string cell array and reshape

조회 수: 13 (최근 30일)
Ugur Sahin
Ugur Sahin 2020년 4월 14일
댓글: Ameer Hamza 2020년 4월 15일
hi guys,
I have to homework my instructor say that, you must enter a string like ' what is the wheather will 17 may 2020 ? ' the program convert to this;
for colon numb of cell=4
-------------------
Wha
Tist (' ' spaces can not count)
Hewh
Eath
....
__ma (every nonstring replace with '_' )
Y___
- first character of every group upper the other ones lower.
ı am second step of progress. ı couldnt reshape cell array that is constitute with charecters at least could anyone help me this subject (you can help me nonstring and space replacement step if you understand) ?
text1=input('please enter the text','s');
text=num2cell(text1);
lengtht=length(text);
linelength=input('enter line length'); %colons
groupnumb=(lengtht/linelength); % group number (row)
reshaped=reshape(groupnumb,linelength,text); % the constitue that ı write above
  댓글 수: 2
James Tursa
James Tursa 2020년 4월 14일
Can you post the actual wording of the assignment?
Ugur Sahin
Ugur Sahin 2020년 4월 14일
I am sorry but publishing official document of faculties is not legal.

댓글을 달려면 로그인하십시오.

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 4월 14일
I think I somewhat understand the question. Get some ideas from this code
str = 'what is the wheather will 17 may 2020 ?';
str = lower(str);
str = strrep(str, ' ', '');
str = regexprep(str, '[^a-z]', '_');
str = [str repmat('_', 1, ceil(numel(str)/4)*4-numel(str))];
str_ = reshape(str, 4, [])';
str_(:,1) = upper(str_(:,1))
Since this is a homework question, so I recommend you to understand the working of each function by reading documentation.
  댓글 수: 4
Ugur Sahin
Ugur Sahin 2020년 4월 14일
ı have done dimensions couldn't pair ı have seen now thanks lot.
Ameer Hamza
Ameer Hamza 2020년 4월 15일
Glad to be of help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by