how to solve this error
Ältere Kommentare anzeigen
I got this error Subscript indices must either be real positive integer or logical
I am tried to removed the range of desired signal from dataset matrix and find the power of that range. then the remaining will be interferance and also i want to find the power of remaining range
the error occured when i want to find the power of interferance
PI=mean(mean(SysSetup.Dataset(:,RI).^2))
this is my code
25 Kommentare
Geoff Hayes
am 24 Feb. 2019
Redflower - so the code is failing at the 7th or 8th line? What can you tell us about RI? i.e. what are the values of this array? Are they positive integers or (as the error message suggests) something else?
Walter Roberson
am 24 Feb. 2019
When you use linspace() you should assume that you are going to get back values that are not necesarily positive integers. If you need positive integers, it is safer to use the colon operator, probably in conjunction with floor() or ceil().
Perhaps in your case it would be sufficient to index at round(RI) instead of at RI .
Redflower
am 25 Feb. 2019
Walter Roberson
am 25 Feb. 2019
You attach code but not sysSetup or the other variables needed for us to run the code to test.
Redflower
am 25 Feb. 2019
Walter Roberson
am 25 Feb. 2019
function ModIdentdataset not defined.
Redflower
am 25 Feb. 2019
Walter Roberson
am 25 Feb. 2019
It looks like it is necessary to call
ModDatasetGenpaper; %to define SysSetup
Train_cumulantpaper; %to define net
something unknown at this point %to define ModIdentdataset
AccuVsSIR2cum; %to do computation
Unfortunately without the code to define ModIdentdataset it is difficult for us to test.
Redflower
am 25 Feb. 2019
Walter Roberson
am 25 Feb. 2019
Okay, finally I can reproduce your error.
You copy the test dataset into RI and you delete the columns given by Rd (a list of positive integers) from that. The result is a 2D numeric array of floating point data with fewer columns that the test dataset.
You then try to index sysSetup.Dataset() using that floating point dataset as indices.
I suspect you want to instead take
RI = setdiff(1:size(Dataset_test,2), Rd);
That is, I suspect you want RI to be the list of remaining indices.
Redflower
am 26 Feb. 2019
Walter Roberson
am 26 Feb. 2019
Ah, yes, if RI is not the same length as Rd then line 16 would trigger an error.
I cannot suggest any solution due to the lack of documentation about what Rd and RI are intended to represent.
Redflower
am 3 Mär. 2019
Walter Roberson
am 3 Mär. 2019
I do not know. If I had documentation about what Rd and RI should mean, then I might be able to assist.
Redflower
am 4 Mär. 2019
Walter Roberson
am 4 Mär. 2019
On line 16, the reference to RI should likely be a reference to Rd
Redflower
am 4 Mär. 2019
Walter Roberson
am 4 Mär. 2019
It is a little after 1 AM where I am. I could go back to examine your code and predict what bugs you might have introduced when you made unknown changes to your code, and then tell you how to correct each of the possibilities... or I could go to bed and check in the morning to see whether you posted your updated code.
Redflower
am 4 Mär. 2019
Redflower
am 5 Mär. 2019
Redflower
am 5 Mär. 2019
Walter Roberson
am 5 Mär. 2019
What are you expecting the linspace() to do for you at that point?
Redflower
am 5 Mär. 2019
Walter Roberson
am 5 Mär. 2019
What do you think the result from that linspace() shoud be?
Are you expecting a series of consecutive integers? Are you expecting a series of integers with a constant gap between them? Are you trying to "sample" a range of integers at as close as you can get to equal partitions? Are you trying to extract the index numbers of all samples belonging to a particular class when the SysSetup information knows where the class starts and how long it is?
Redflower
am 5 Mär. 2019
Antworten (0)
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
