Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

I need to create a 1x6 string combining strings?

조회 수: 1 (최근 30일)
Jose Grimaldo
Jose Grimaldo 2020년 2월 4일
마감: MATLAB Answer Bot 2021년 8월 20일
Screenshot (204).png
Screenshot (203).png
I'm having trouble creating a 1x6 string setting X="I Love Pizza Not Vegatibles" using the variables L,I,J and also adding spaces. I'm assuming i have to combine strings to create a 1x6 string. There is also a space at the beginning .
  댓글 수: 2
Stephen23
Stephen23 2020년 2월 4일
What are "Vegatibles" ? Did your professor mean https://en.wikipedia.org/wiki/Vegetable ?
Jose Grimaldo
Jose Grimaldo 2020년 2월 4일
I think is a typo, i think it was supposed to be "Vegetable"

답변 (2개)

KSSV
KSSV 2020년 2월 4일
Method 1:
% Add space with the strings itself
s1 = " I " ;
s2 = " LOVE " ;
s3 = " MATLAB " ;
iwant = [s1,s2,s3] ;
Method 2
% Add space at the time of joining
s1 = "I" ;
s2 = "LOVE" ;
s3 = "MATLAB" ;
iwant = [s1,' ',s2,' ',s3] ;

Bhaskar R
Bhaskar R 2020년 2월 4일
Use + operator for string data type concatanation
X = space+ L+ space+ J+ space+ I+ space+ C; % this works for you

Community Treasure Hunt

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

Start Hunting!

Translated by