Forming loop to perform same action
Afficher commentaires plus anciens
I am having problem creating the loop for the task.
Thres = 0.17;
istrue1= ((x>=928 & x<=1139) & y>=Thres)|((x>=2527 & x<=2856) & y>=Thres)|((x>=4113 & x<=4376) & y>=Thres)|((x>=5464 & x<=5643) & y>=Thres)|((x>=7254 & x<=7604) & y>=Thres);
TP = sum(istrue1);
Using the command I can find out the value of TP for a particular value of thres. But I want to vary the value of thres from 0:0.1:1 and want to get 10 values of TP simultaneously rather than changing Thres each time. I know it is easy but not for me. Please help.
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 4 Avr 2020
Modifié(e) : Image Analyst
le 4 Avr 2020
Rather than be so complicated, break it into parts, like
term1 = (x>=928 & x<=1139)
term2 = y>=Thres
term3 = (x>=2527 & x<=2856)
and so on. Then look at the size and values of each term. This is just basic debugging... Then
put Thresh into a loop
Thres = [0 : 0.1 : 1];
for k = 1 : length(Thres)
thisThres = Thres(k);
istrue1 = ...... function thisThresh instead of Thres
end
4 commentaires
SUBHAJIT KAR
le 4 Avr 2020
Modifié(e) : SUBHAJIT KAR
le 4 Avr 2020
Image Analyst
le 4 Avr 2020
Modifié(e) : Image Analyst
le 4 Avr 2020
You can preallocate using the lengths of the x and Thres vectors like this:
z = zeros(length(Thres), length(x));
By the way, the length of Thres is not 10:
>> length( 0:0.1:1 )
ans =
11
SUBHAJIT KAR
le 5 Avr 2020
SHAIK
le 26 Fév 2024
from the above code what is y.
Catégories
En savoir plus sur Performance and Memory dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!