function plotting(filename, distance, r0, M, jmax, imax, zmax, rmax, pm)
    %% otevreni souboru
    fid = H5F.open(filename);
    % spocitej j, zaokrouhli na desitky a pricti 1
    j_number = round(distance/(r0*zmax)*jmax,-1)+1;
    % pokud zada prilis velke nebo zaporne j
    while j_number > jmax || j_number < 1
        distance = input('Neplatna vzdalenost. Zvolte prosim spravnou: ');
        j_number = round(distance/(r0*zmax)*jmax,-1)+1;
    end
    % vycucni si G a H pri danem j
    g_name = strcat('/G/j',num2str(j_number));
    h_name = strcat('/H/j',num2str(j_number));
    gid = H5D.open(fid,g_name);
    hid = H5D.open(fid,h_name);
    G = H5D.read(gid);
    H = H5D.read(hid);
    
    %% inicializace plot funkci, 
    
    f = 0; % vysledna funkce
    fz = 0;
    p0 = 2e-005;
    
    %% amplitudy bezrozmerne rychlosti a tlaku
    p_amps = zeros(1,M);
    w_amps = zeros(1,M);
    
    %% vykresleni intenzity zvuku Lp vsech harmonickych
    tau = linspace(-2*pi,2*pi,10000);
    harmonics = 1:M;
    
    for k=1:M
        %f = f + G(k,1)*sin(k*tau)+H(k,1)*cos(k*tau);
        w_amps(k) = sqrt(G(k,1)^2+H(k,1)^2); %amplitude
        p_amps(k) = w_amps(k)*pm;
    end
    for k=1:M
        f = f + G(k,1)*sin(k*tau)+H(k,1)*cos(k*tau);
    end
    for k=1:20
        fz = fz + G(k,1)*sin(k*tau)+H(k,1)*cos(k*tau);
    end
    %%w_amps
    Lp = 20*log10(max((p_amps/p0),1));
    
    figure
    hold on
    grid on
    harmonics = harmonics(1:100);
    Lp = Lp(1:100);
    bar(harmonics, Lp, 'red');
    xlabel('frekvence [kHz]')
    ylabel('L_p [dB]')
    figure
    hold on
    grid on
    plot(tau,f);
    xlabel("\tau´ [-]")
    ylabel('w [-]')
    figure
    hold on
    grid on
    plot(tau,-fz);
    xlabel("\tau´ [-]")
    ylabel('w [-]')
    
    %% pricne rozlozeni rychlosti
    j = 1:150:jmax;
    num_of_j = length(j);
    W_pricne = zeros(num_of_j,imax);
    s_step = linspace(0,rmax,imax);
    figure
    idx = 1;
    for step=j
        g_name = strcat('/G/j',num2str(step));
        h_name = strcat('/H/j',num2str(step));
        gid = H5D.open(fid,g_name);
        hid = H5D.open(fid,h_name);
        G = H5D.read(gid);
        H = H5D.read(hid);
        W = zeros(1, imax);
        
        k = 1; %harmonicka jejiz prubeh sleduju
        for i=1:imax
            W(k,i) = sqrt(G(k,i)^2+H(k,i)^2);
        end
        W_pricne(idx,:) = W(k,:);
        plot(s_step, W(k,:));
        xlabel('\xi [-]')
        ylabel('w [-]')
        hold on
        idx = idx+1;
    end
    R = 0.1;
    x = linspace(-rmax*R,rmax*R,imax);
    y = linspace(0,zmax*r0,num_of_j);
    %% podel osy sigma
    forward = 1:10:jmax;
    W = zeros(1, length(forward));
    k = 1; %harmonicka jejiz prubeh sleduju
    idx = 1;
    for j=forward
        g_name = strcat('/G/j',num2str(j));
        h_name = strcat('/H/j',num2str(j));
        gid = H5D.open(fid,g_name);
        hid = H5D.open(fid,h_name);
        G = H5D.read(gid);
        H = H5D.read(hid);
        W(idx) = sqrt(G(k,1)^2+H(k,1)^2);
        idx = idx+1;

    end
    o_step = linspace(0,zmax,length(forward));
    figure
    plot(o_step, W)
    xlabel('\sigma [-]')
ylabel('w [-]')

    
end