필터 지우기
필터 지우기

insert elements of array in a string one by one

조회 수: 1 (최근 30일)
Nabhdeep Bansal
Nabhdeep Bansal 2015년 4월 26일
댓글: Stephen23 2015년 4월 27일
i have a string containing url 'http://www.upsc.gov.in/cgi-bin1/ENGG/Marks/engg_wq_marks_response.pl?roll_no= 098909 ---'
the digits in the bold are to be changed at every iteration of the for loop and the new element of an array are to be inserted. But MATLAB does not consider a variable inside a string.
How can i solve this problem?
Thanks in advance.
  댓글 수: 1
Stephen23
Stephen23 2015년 4월 27일
This is easy using sprintf, and the documentation contains plenty of examples.

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

채택된 답변

Jan
Jan 2015년 4월 26일
편집: Jan 2015년 4월 26일
Depending on the inputs something like this might help:
for k = 98900:98999
S = sprintf(['http://www.upsc.gov.in/cgi-bin1/ENGG/Marks', ...
'/engg_wq_marks_response.pl?roll_no= %06d ---'], k)
end
Or:
C = {'098909', '098910', '098911'};
for k = 1:3
S = sprintf(['http://www.upsc.gov.in/cgi-bin1/ENGG/Marks', ...
'/engg_wq_marks_response.pl?roll_no= %s ---'], C{k})
end
If you provide the definition for the changing part of the string, a matching answer is more likely.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by