Forming loop to perform same action
显示 更早的评论
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.
采纳的回答
更多回答(1 个)
Image Analyst
2020-4-4
编辑:Image Analyst
2020-4-4
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 个评论
SUBHAJIT KAR
2020-4-4
编辑:SUBHAJIT KAR
2020-4-4
Image Analyst
2020-4-4
编辑:Image Analyst
2020-4-4
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
2020-4-5
SHAIK
2024-2-26
from the above code what is y.
类别
在 帮助中心 和 File Exchange 中查找有关 Performance and Memory 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!