필터 지우기
필터 지우기

Problem with string assembly

조회 수: 1 (최근 30일)
judy abbott
judy abbott 2016년 8월 14일
댓글: judy abbott 2016년 8월 15일
Hy all for my code,
V_AA = [100; 200]
L_AA = length(V_AA)
S_AA = num2str(V_AA)
for i=1:L_AA
F_AA{i} = ['N°: ' S_AA(i)];
end
i'm unable to get :
F_AA{1} = N°: 100
F_AA{2} = N°: 200
Thanks

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 8월 14일
편집: Azzi Abdelmalek 2016년 8월 14일
V_AA = [100; 200]
L_AA = length(V_AA)
for i=1:L_AA
F_AA{i} = sprintf('N°: %d', V_AA(i))
end
%or without for loop
F_AA=regexp(sprintf('N°: %d ', V_AA'),'N°: \d+','match')
  댓글 수: 1
judy abbott
judy abbott 2016년 8월 15일
Please for print how I do ?
i = 1
N°: 100
i = 2
N°: 200
Thank

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

추가 답변 (1개)

Geoff Hayes
Geoff Hayes 2016년 8월 14일
Judy - since S_AA is an array of characters, then
S_AA(i)
returns the first character only in the ith row. To return all characters, you would need to do
for i=1:L_AA
F_AA{i} = ['N°: ' S_AA(i,:)];
end
  댓글 수: 1
judy abbott
judy abbott 2016년 8월 14일
Thank you for the explication

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

카테고리

Help CenterFile Exchange에서 Engines & Motors에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by