Forming loop to perform same action
Mostra commenti meno recenti
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.
Risposta accettata
Più risposte (1)
Image Analyst
il 4 Apr 2020
Modificato: Image Analyst
il 4 Apr 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 Commenti
SUBHAJIT KAR
il 4 Apr 2020
Modificato: SUBHAJIT KAR
il 4 Apr 2020
Image Analyst
il 4 Apr 2020
Modificato: Image Analyst
il 4 Apr 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
il 5 Apr 2020
SHAIK
il 26 Feb 2024
from the above code what is y.
Categorie
Scopri di più su Performance and Memory in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!