how to call nested structure and cell array?

if I want to call the firts column of the data.timepoints how can I do that? I mean the "time" column.
I really appreciate any help.

 采纳的回答

Jon
Jon 2019-8-9
编辑:Jon 2019-8-9
I'm not sure exactly what you mean by "call the first column of the data.timepoints"
If you wanted to assign some other variable (I'm not sure why you would want to do this) to hold the time values you could use, for example
t = data.timepoints.time
If you wanted to perform some mathematical operation on the vector of times you could do it directly for example
y = 2*data.timepoints.time + 10
If this is not what you are asking, then can you please clarify. Best is to give a simple example (short piece of code to demonstrate) of what you are trying to do, explain the problems that you encounter, and copy and paste the full text of any error messages that you encounter

7 个评论

Sorry I didn't look closely enough at your screen shot to realize there was one more level of nesting. As indicated by @madhan ravi so you should refer to the times as data.timepoints.time rather than just data.timepoints. To avoid confusion I have edited my original post accordingly to give the correct name. I would suggest accepting @madhan ravi's answer if that is all you are asking.
Thanks for your help. How can I choose the one the first row in the data.timepoints.time? I mean choosing time "0". I tried data.timepoints.time{1} and data.timepoints.time(1) both gave me error.
I also need to use this in a loop and do some calculations, how can I find the range of the data.timepoints.time? Here the range is 6 but it might change. I wanted to have some basic syntaxed to work with structures. I checked here but did not answer my question.
Mind uploading the data as .mat file?
With the structure you show in your screen shot you should be able to retrieve the first element of time using
t0 = data.timePoints.time(1)
What error did you get? As @madhan ravi says it would be helful if you uploaded your variable data so we could try
You should be able to get the number of elements in your time vector using
length(data.timePoints.time)
The error is get is : Expected one output from a curly brace or dot indexing expression, but there were 6 results.
Zeynab, will you attach your data ???
It is huge data and I did some precalculations. I was trying to put all structure in an excel file to send it here but I got the error that it is huge. Any suggestion?

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Structures 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by