Indexing numbers only finding NaN
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, all,
I am trying to index values from my files that are before a switch condition. The code knows the read at the switch, but I need the value before. I have been messing with it for a couple work days.
%Find the indices of trials before the side of weight switches in object
indxTrialBeforeWeightSwitch = indxMinoritySide-1;
%only use the positive values (otherwise includes if there was a weight switch)
positiveIndices = find(indxTrialBeforeWeightSwitch>0);
indxTrialBeforeWeightSwitch = indxTrialBeforeWeightSwitch(positiveIndices);
%make vectors to store the data:
currentSeqMComValues = NaN(maxSeqReps, 1);
MComBeforeSwitch = NaN(maxSeqReps, 1);
currentSeqTrialNums = NaN(maxSeqReps, 1);
trialBeforeMComSwitch = NaN(maxSeqReps, 1)
%store the ouptut of the trials before the CoM switch
trialBeforeSwitchVec = [trialBeforeSwitchVec, trialBeforeMComSwitch'];
MComBeforeSwitch = [MComBeforeSwitch, currentMCOMBeforeSwitch'];
This is what I currently am looking at. All I get for all the variables listed above, except for currentMComBeforeSwitch, is NaN.
Sorry if this is not enough information, I am still in my learning stages of matlab.
Thank you!
3 comentarios
Walter Roberson
el 31 de Mayo de 2023
trialBeforeSwitchVec = [trialBeforeSwitchVec, trialBeforeMComSwitch'];
We are not given any information about trialBeforeSwitchVec. But we know that trialBeforeMComSwitch was assigned on the line above according to
trialBeforeMComSwitch = NaN(maxSeqReps, 1)
You appear to be building up trialBeforeSwitchVec incrementally, and you do not show any code in which you put any non-nan value into trialBeforeMComSwitch so it would not be surprising at all to discover that afterwards the entire trialBeforeMComSwitch is NaN.
MComBeforeSwitch = NaN(maxSeqReps, 1);
All NaN.
MComBeforeSwitch = [MComBeforeSwitch, currentMCOMBeforeSwitch'];
We have no information about currentMCOMBeforeSwitch but MComBeforeSwitch was assigned NaN.
If currentMCOMBeforeSwitch has even one non-NaN value then [MComBeforeSwitch, currentMCOMBeforeSwitch'] must have at least one non-NaN entry unless the [] fails.
Respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!