MATLAB Answers

Any suggestions to this algorithm?

1 view (last 30 days)
Azar Nejad
Azar Nejad on 24 Aug 2018
Commented: Image Analyst on 25 Aug 2018
Hi all,
I have a big problem with my algorithm. I really don’t know what can I do and so confused? If someone have any suggestion that would extremely helpful.
for counter=1:(end of the struct)
*check condition 1
If *condition 1 is true then
counter plus to check the condition 2
Between conditions 1 & 2 there is not fixed amount of data maybe non, 2 or more.
So I need that counter in this loop too.
  4 Comments
Image Analyst
Image Analyst on 25 Aug 2018
Azar's "Answer" moved here since it tries (unsuccessfully) to clarify the original post rather than be an "Answer" to the original post.
Thanks all for your support.
This is part of my data:
I deleted some rows to show 'UserEvent'
I want 'X' & 'Y' data between 'onset' and 'offset' where I have 'L' in the 'EventType'
For example in '#Message: onset_P1_8'
I want a variable struct named 'P1_8' or p(1,8) (I really don't know what kind of variable I need!) and the value for this var is []
Sincerely

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 25 Aug 2018
No, you don't (or shouldn't) want this, even though you, and too many other beginners, think so. It can't be stressed too strongly. See the FAQ: https://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F Just don't do it.
You do NOT want to have a struct variable where the name of that variable is determined by part of a string in the "End" field of your structure. If you don't know what possible strings would be there at run-time when you read in your data then how can you refer to that variable with the unknown name when you're writing the code? You can't. So don't do it.
  2 Comments
Image Analyst
Image Analyst on 25 Aug 2018
"Doesn't work" is not very descriptive. At least attach your "Subject" variable in a .mat file with the paper clip icon in case people want to run your code. And see this link so people can read your code.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!