Filter löschen
Filter löschen

why this code doesn't give me plot line (without error)?

1 Ansicht (letzte 30 Tage)
Samira Fakhraeian
Samira Fakhraeian am 16 Nov. 2021
Beantwortet: Mihir am 11 Jun. 2023
I wrote this piece of code for plotting 'Theoretical probability of a successful search versus Jaccard similarity' figure. The output is an empty plot. I dont know what should I change. the original function is in the picture I have replaced some variables.
clear
clc
% input paramters
% b=100, r=4
v=2;
s=0:0.1:10;
for i=0:1
for j=1:size(s,1)
pr(j) = 1 - sum ((factorial(100)/(factorial(i).*factorial(100 - i))).*(1-(s(j).^4).^(100-i)).*((s(j).^4).^i));
end
end
plot(pr, s, 'r'), xlabel('Jaccard Similarity'), ylabel('Probability of Successful Search')

Antworten (1)

Mihir
Mihir am 11 Jun. 2023
According to the labels mentioned, there is a mismatch between the x labels and the parameter passed the probability and for y label the parameter passed is Jaccard Similarity. Instead it should be swapped. This is the correct approach to see the expected behaviour
plot(s, pr, 'r'), xlabel('Jaccard Similarity'), ylabel('Probability of Successful Search');
Hope this helps to show the expected graph.

Kategorien

Mehr zu Statistics and Machine Learning Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by