Any suggestions to this algorithm?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
dpb
2018-8-24
I agree w/ both posters; while I can kinda' get the drift of what you're trying to say, not enough given to really do anything with.
I think showing a (smallish) example of input and then the desired result and how you determined that result will be the only way anybody will be able to help here...
Image Analyst
2018-8-25
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/195268/image.png)
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
回答(1 个)
Image Analyst
2018-8-25
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 个评论
Image Analyst
2018-8-25
"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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Debugging and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!