0
votes

I have 30 files (UE1.dat, UE2.dat, ......), all of the them consist of 2 columns (the first one is the delay and the second one is its CDF). So because i don't have the CDF value for all delays in the range [100:600], i had to interpolate the second columns according to the first one in all those 30 files and after that to normalize the data between 0 and 1. Everything works perfect until now.

In the end I have to plot a graph, which consists of x, y and the y error-bars. x is the range (100:1:600), y is the mean for every row of the interpolated data for every x from 100 to 600 by step 1, and for the y error-bars I calculate the standard deviation for every y row as well.

But when I plot the data with error bars it looks weird and i have some strange x dashes, while if I plot only x against y everything looks good. Can you give me some hints how to troubleshoot the issue with the y error-bars, maybe i miss something. Below the MATLAB code is attached and the graphs as well.

clc;
close all;
clear all;
% xq1 = (100:600)
NUM_UES = 30;
NUM_SAMPLES = 501;

for i=1:NUM_UES
%% Loading data
x = load(strcat('C:\Users\tgetsov\Documents\BA THESIS\temp_200\ral\UE',num2str(i),'.cdf.dat'));
y = strcat('C:\Users\tgetsov\Documents\BA THESIS\temp_200\ral\UE',num2str(i),'.cdf.dat');

xq = 100:1:600;
Result(:, i) = interp1(x(:,1), x(:,2), xq, 'linear', 'extrap');
Result_norm(:, i) = (Result(:, i) - min(Result(:, i)))/(max(Result(:, i) - min(Result(:, i))));
end
% p=0:length(Result)-1;
%%Plotting Data
% figure(i);
% % plot(p,Result); hold on;grid;
% plot(xq_i,Result_i);
% hold on;
% grid;
for k=1:NUM_SAMPLES
    avg(k) = mean(Result_norm(k,:));
    min_30_ral(k) = min(Result_norm(k,:),[],2);
    max_30_ral(k)= max(Result_norm(k,:),[],2);
    stdev(k) = std(Result_norm(k,:))*ones(size(xq(:, k)));
    variance(k) = var(Result_norm(k, :));    
end
    v = variance;
    v2 = zeros(size(v));
    v2(1:50:end) = v(1:50:end);
    m = stdev;
    m2 = zeros(size(m));
    m2(1:50:end) = m(1:50:end);
%     [F , X] = ecdf(avg)

figure (1)
% errorbar(xq,avg,min_30_ral,max_30_ral);
% errorbar(xq,avg,m2);
% errorbar(xq,avg,v2);

errorbar(xq,avg,m2);
hold on;
grid;

figure (2)
plot (xq, avg);
hold on;
grid;

x against y:

enter image description here

x against y with error bars:

enter image description here

1
There is no problem here. Those are not "strange dashes" but the errorbar upper and lower limits. You have very small error margins between 0-320 so the bar appear small. - Ander Biguri
ok it is more clear to me now, but how can i plot only the vertical errors without the horizontal ones? - Trifon Getsov

1 Answers

0
votes

To remove the errorbars you can use the answer provided by david szotten in the following Matlab Central question: http://uk.mathworks.com/matlabcentral/newsreader/view_thread/167875

I will copy and paste the answer provided there:

removeErrorBarEnds.m :
-------------
function removeErrorBarEnds(hErrBar)
%removeErrorBarEnds
% removeErrorBarEnds(hErrBar) removes the lines 
above/below errorbars
% generated by the matlab function hErrBar = errorbar()
%
% Example:
% x = 1:10;
% y = sin(x);
% e = std(y)*ones(size(x));
% h = errorbar(x,y,e)
% oldAx = axis;
% removeErrorBarEnds(h)
% axis(oldAx)

% david szotten

%use length of xdata to find the right handle
%there may be an easier way to do this
dataLen = length( get(hErrBar, 'xdata') );

%objects to try, one of this is the errorbars
candidateList = findall(hErrBar);

for candidate = candidateList(:)'
        candLen = length( get(candidate, 'xdata') );

        %found it
        if candLen == 9 * dataLen
                xOrg = get(candidate, 'xdata');
                yOrg = get(candidate, 'ydata');

                %we only want the first 3 out or every 9
                valuesToExtract = find( kron( ones
(1,dataLen), [ones(1,3) zeros(1,6)]) );
                xNew = xOrg(valuesToExtract);
                yNew = yOrg(valuesToExtract);

                set(candidate, 'xdata', xNew);
                set(candidate, 'ydata', yNew);
        end
end

end

Note: I'm posting this question here in order to make sure the knowledge (and code) is also in STACKOVERFLOW.