Multiplying a string with 1 or 0
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Davor Pavlovski
am 9 Dez. 2019
Bearbeitet: the cyclist
am 9 Dez. 2019
Check_B = 0; % checks if condition for B is satisfied
string = strcat('A', Check_B*'+B')
I want to be able to add one string to another only if a condition is satisfied, without making an if statement or switch statement.
If Check_B = 0, ('+B') will not be added, otherwise it will be.
The code provided works, however it gives a warning.
Is there a cleaner way to do the same? (I believe this is possible in Python for example)
0 Kommentare
Akzeptierte Antwort
the cyclist
am 9 Dez. 2019
Bearbeitet: the cyclist
am 9 Dez. 2019
Here is one way:
c = ['A', repmat('+B',Check_B)];
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Call Python from MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!