Azzera filtri
Azzera filtri

how to solve this issue?

1 visualizzazione (ultimi 30 giorni)
vijay chandra
vijay chandra il 17 Ott 2017
Commentato: vijay chandra il 17 Ott 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)

Risposta accettata

Guillaume
Guillaume il 17 Ott 2017
Modificato: Guillaume il 17 Ott 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 Commento
vijay chandra
vijay chandra il 17 Ott 2017
I will get structures as I told like above. Thank you Guillaume. Your commands helped me to get what I want exactly.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Structures in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by