how to solve this issue?

1 view (last 30 days)
vijay chandra
vijay chandra on 17 Oct 2017
Commented: vijay chandra on 17 Oct 2017
Log_name=strtrim(['ArxmlLog.Struct_Pdus.',strcat('Struct_Pdu',num2str(pduCount))]);
If I use this line I will get structure like Struct_Pdu_1
But I want to get like this Struct_Pdu.(1)
Struct_Pdu_1 ====> Struct_Pdu.(1)
Instead of _1 =====> .(1)

Accepted Answer

Guillaume
Guillaume on 17 Oct 2017
Edited: Guillaume on 17 Oct 2017
If I use this line I will get structure like Struct_Pdu_1
a) you don't get a structure at all, you get a char array (with the word struct in it).
b) what you get is of the form ArxmlLog.Struct_Pdus.Struct_Pdu1, no _ between Pdu and the number.
c) that's a needlessly complicated syntax, we have an strtrim that has nothing to strim and a redundant strcat that does the same as the [] it's embedded in.
I'm not sure what you're trying to do. If you are trying to create a char array, then:
Log_Name = sprintf('ArxmlLog.Struct_Pdus.Struct_Pdu(%d)', pduCount);
would be one way. Possibly, the 2nd Struct_Pdu is supposed to come from a variable, in which case:
fname = 'StructPdu';
Log_Name = sprintf('ArxmlLog.Struct_Pdus.%s(%d)', fname, pduCount);
  1 Comment
vijay chandra
vijay chandra on 17 Oct 2017
I will get structures as I told like above. Thank you Guillaume. Your commands helped me to get what I want exactly.

Sign in to comment.

More Answers (0)

Categories

Find more on Structures in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!