i am getting data from a sensor in serial communication, How to delete the first string i get from it

after connection i want to print just acc , gyro and mag values. I get 'initializationsuccessful' as my first data set . I dont want that to be there. Help me out
for i= 1:50
data =fscanf(s,'%s');
if data(i)== 'initializationsuccesful!'
delete(data)
else
Acc_Val = data(:,1:21)
end
end

3 件のコメント

jonas
jonas 2018 年 7 月 10 日
I do not understand the question. Can you describe the data and the desired output?
I make a serial communication with an arduino and get the data of accelerometer mag and gyro values my data comes in as a string. 's' is the object i created for serial communication
data =fscanf(s,%s) % gives me the data from the arduino
i want my vector size to be 500. so when I run it in for loop
for i= 1:50
data =fscanf(s,'%s');
end
my output is: data = initializationsuccesful!
data = ax:123ay:23az:1234gx:23gy:50gz:43mx:23my:123mz:234
and goes on.
I use,
A_x(:,i) = str2num(data(:,4:8))
to get my vector. but since 'initializationsuccessful!' is not a number i am unable to form my vector. so how can I do it ???? this is my question
jonas
jonas 2018 年 7 月 11 日
編集済み: jonas 2018 年 7 月 11 日
Ok! Could you upload the txt file or a small part of the text file (that still gives you the error),so we have something to work with?

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Arduino Hardware についてさらに検索

質問済み:

2018 年 7 月 10 日

編集済み:

2018 年 7 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by