Any suggestions to this algorithm?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
dpb
am 24 Aug. 2018
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
am 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:
![](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
Antworten (1)
Image Analyst
am 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 Kommentare
Image Analyst
am 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.
Siehe auch
Kategorien
Mehr zu Debugging and Analysis 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!