Indexing numbers only finding NaN
이전 댓글 표시
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
Walter Roberson
2023년 5월 31일
.. There are no locations where indxMinoritySide-1 > 0 ?
Catherine
2023년 5월 31일
Walter Roberson
2023년 5월 31일
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.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!