Tom Kealy
Tom Kealy

Reputation: 2669

Plotting multiple ROC curves

I need to vary a parameter in my experiments, and save the X,Y from perfcurve in each run. Unfortunately, they are a different size each time.

for ii=1:length(myparams)
    %some previous calculations
    [X,Y,T,abc] = perfcurve(true, scores, 1);
    X_all(ii, :) = X;
    Y_all(ii, :) = Y;
end
Plot(X_all, Y_all)

I'd like to get this working, but I can't figure out how to save the Xand Y each time through the loop.

Upvotes: 0

Views: 277

Answers (1)

Richard
Richard

Reputation: 1060

Saving vectors of unequal length is easily implemented by a cell array.

Here the adaption of your problem:

X_all = cell([1 length(myparams)]);
Y_all = cell([1 length(myparams)]);

for ii=1:length(myparams)
    %some previous calculations
    [X,Y,T,abc] = perfcurve(true, scores, 1);
    X_all{ii} = X;
    Y_all{ii} = Y;
end

figure, hold on
for ii=1:length(myparams)
    plot(X_all{ii}, Y_all{ii});
end

Upvotes: 3

Related Questions