obtain answer in brackets

18 views (last 30 days)
DavidL88 on 2 Jul 2020
Commented: DavidL88 on 2 Jul 2020
I have some data in a 3x1 struct with 2 fields. The data is stored in this fashion [0.1000,0.2500]. When I retrieve the dat using this code Times_period = S_times(1).Times I get ans = 0.1000 0.2500. I want to retieve exactly this [0.1000,0.2500] (ie with square brackets included). Can anyone advsie how I do this?
I tried Times_period = {"[",S_times(1).Times,"]"}. But I get this = 1×3 cell array {["["]} {1×2 double} {["]"]}
Tried other variations but no success.

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 2 Jul 2020
DavidL88 on 2 Jul 2020
That makes sense. Thank you!

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 2 Jul 2020
You can use sprintf() to create a string with any appearance you want.
Or fprintf() to display it with any appearance you want.


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!