how to write program for following problem
3 ビュー (過去 30 日間)
古いコメントを表示
if i get string as an input in COM1 and i have to make a shape according to that string. the string has characters- A,A',B,B',C,C',D,D' and these characters represent lines which have to be drawn. A represents line in upward direction of length say x, then A' represents line in upward direction but the length of the line of half of A ie, x/2, similarly with the other characters, where A represents upward line, B-downward line, C-left line and D- right line. Ex: if the string i receive a string AD'BA'C' then the output should be "A" in segmented form
0 件のコメント
回答 (2 件)
Matt Kindig
2013 年 8 月 27 日
編集済み: Matt Kindig
2013 年 8 月 27 日
I'm not going to given you the entire code, but to get you started, here's how you can do the parse:
a = 'AD''BA''C'''; %sample input string
%separate into various characters
chars = regexp(a, '[ABCD](''*)', 'match'); %characters are in a cell array
for k=1:length(chars),
c = chars{k}; %for each character
%fill in the plotting code here!
end
0 件のコメント
Walter Roberson
2013 年 8 月 27 日
Hint:
I(curx:curx+L,:) = 1; %line of length L drawn vertically
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Use COM Objects in MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!