Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Could you please correct my program for single variable but different size and many outputs.

1 回表示 (過去 30 日間)
Rakesh Yadav Kodari
Rakesh Yadav Kodari 2019 年 2 月 27 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I have a single variable called A. it is a serial ports output and size is infinity. so it gives the output with many different sizes.
for example A = '9/027B/029B/02C1/0245/0335/01A8/0365/0110/0335/00D5/0323/00B3/034E/0038/0359/-FFC3/032
A =023C/031C/0286/02CA/02AD/027A/030B/0237/0380/019B/039E/0122/03AD/00D5/03D2/
A = 4/0209/00AD/01D8/0083/01A2/005F/0173/0055/01B7
A = 0A5/026F/0114/0241| and so on
Can I record the Output A from specific Delimiters in to another variable, M and L are starting and ending delimiters
if (positionofM == strfind(A, 'M')) && (PositionofEnd == strfind(A, L))
newframes = A(positionofM:PositionofEnd);
end
  3 件のコメント
Rakesh Yadav Kodari
Rakesh Yadav Kodari 2019 年 2 月 27 日
M and L was an example.
The problem is each time I get the output as A = something..............., I am losing the previous output.
I need to track the A with the starting and ending delimiters and save it to another variable.
Is there any possible way?
Jan
Jan 2019 年 4 月 3 日
@Rakesh: If you post a working example, it is easy to suggest a modification. Expanding a not working example is somewhat artificial.

回答 (2 件)

Bob Thompson
Bob Thompson 2019 年 4 月 2 日
You are losing the different values of A because you are overwriting the value each time you run a new calculation. The way to prevent this from happening is with indexing.
  1 件のコメント
Jan
Jan 2019 年 4 月 3 日
The link is not useful. I assume this is a typo.

Jan
Jan 2019 年 4 月 3 日
編集済み: Jan 2019 年 4 月 3 日
A{1} = '9/027B/029B/02C1/0245/0335/01A8/0365/0110/0335/00D5/0323/00B3/034E/0038/0359/-FFC3/032'
A{2} = '023C/031C/0286/02CA/02AD/027A/030B/0237/0380/019B/039E/0122/03AD/00D5/03D2/'
A{3} = '4/0209/00AD/01D8/0083/01A2/005F/0173/0055/01B7'
...and so on
Use a cell array to store variables with different sizes or classes.
A modern string object would be fine also for this example.

Community Treasure Hunt

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

Start Hunting!

Translated by