How can I parse A2L file Function Section ?
12 次查看(过去 30 天)
显示 更早的评论
Dear Users,
I would like to parse a2l file function interaction. But I could not be succussful.
I have no experience on string processing side of Matlab. Could you help me how can I get function infromations from a2l file?
Example A2L Function Section:
/begin FUNCTION
Vehicle
"0.0.1 Function Name"
/begin DEF_CHARACTERISTIC
Label_1 Label_2 Label_3 Label_4
/end DEF_CHARACTERISTIC
/begin IN_MEASUREMENT
Label_5
/end IN_MEASUREMENT
/begin OUT_MEASUREMENT
Label_7 Label_8 Label_9
/end OUT_MEASUREMENT
/begin LOC_MEASUREMENT
Mp_1 Mp_2 Mp_3 Mp_4 Mp_5
/end LOC_MEASUREMENT
FUNCTION_VERSION "0.0.1"
/end FUNCTION
My Code to READ A2L FUNCTION NAME AND FUNCTION DESCRIPTION
index_number=zeros(k,1);
index_number_a=zeros(k,1);
mm=0;
nn=0;
for i=1:1:k
if (a(i)=="/begin FUNCTION")
nn=i;
index_number_a(i)=nn;
end
end
for kk=1:1:k
if (a(kk)=="/begin DEF_CHARACTERISTIC")
mm=kk;
index_number(kk)=mm;
end
end
index_number_anew=find(index_number_a);
index_number_new=find(index_number);
num=length(index_number_anew);
for pp=1:1:num
t=index_number_anew(pp);
r=index_number_new(pp);
temp=r-t;
for counter=(t+1):1:(r-1)
temp1=strfind(a(counter),'"');
temp2=strcmp(a(counter),"");
if (~isempty(a(counter)) && isempty(temp1)&&(temp2==0))
FunctionNaming(counter)=a(counter);
end
if (~isempty(a(counter)) && ~isempty(temp1)&&(temp2==0))
FunctionDescription1(counter)=a(counter);
end
end
end
Could you offer a suggestion to read a2l file on matlab I will be appreciate to you.
0 个评论
回答(2 个)
Shivam Sardana
2019-9-25
You can use xcpA2L function to read A2L file. You can refer to the link for the documentation of A2L File Management: https://www.mathworks.com/help/vnt/a2l-file-management.html
2 个评论
ganesh dutt
2022-3-8
Hello Shivam, I am trying to Parse the A2l file in Matlab using xcpA2L function but I am getting error like " Reference to non-existent field 'ROOT'". Please answer my query so that I can move forward with my work.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!