help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Subplot breaks working code


From: Octavio
Subject: Subplot breaks working code
Date: Thu, 15 Mar 2018 06:36:59 -0700 (MST)

I have used many times the subplot function, but today I don't know why it is
generating an error. The relevant part of the code is:

f = 1e3; % Frecuencia de la señal real.
fs1 = 20*f; % Frecuencia a la que samplea 1.
fs2 = 20.1*f; % Frecuencia a la que samplea 2.
fs_teorica = 10*f; % Frecuencia a la que yo creo que están sampleando los
voltímetros.
N_CICLOS = 10; % Número de ciclos a samplear.

t = linspace(0, N_CICLOS/f); % Eje real de tiempo.
ts1 = 0:fs1^-1:max(t); % Tiempos en los que samplea 1.
ts2 = 0:fs2^-1:max(t); % Tiempos en los que samplea 2.

while length(ts1) != length(ts2)
        if length(ts1) > length(ts2)
                ts1(end) = [];
        else
                ts2(end) = [];
        end%if
end%while

samples_1 = sin(2*pi*f*ts1);
samples_2 = sin(2*pi*f*ts2);

TITULO_GRAFICO = sprintf('%.2i', round(datevec(now())));
x_pixels = X_mm*3.779527559*PROPORCION(1); 
y_pixels = round(PROPORCION(2)*x_pixels);
clear('leyenda');
clear('graf');
figure('Position',[0,0,x_pixels,y_pixels]); hold on; 
        plotf = @plot; % Reemplazar por «semilogy», «loglog», etc y 
automáticamente
pone los tics
        
        *%~ subplot(2,1,1); % If this line is not comented, the error occurs!*
        k = 1;
        graf(k) = plotf(samples_1);
                leyenda{k} = 'Samples 1';
        k++;
        graf(k) = plotf(samples_2);
                leyenda{k} = 'Samples 2';
        
        for k = 1:length(graf)
                set(graf(k),
                        'LineWidth', 2,
                        'Marker', '.',
                        'Color', COLORES{k});
        end%for

        % CONFIGURACION DEL GRAFICO 
---------------------------------------------
        XLABEL = 'Eje x';
        YLABEL = 'Eje y';
        % -------------------------------------------------------
        % title(TITULO_GRAFICO, "FontSize", TITLE_FONT_SIZE);
        xlabel(XLABEL, 'FontSize', AXIS_LABEL_FONT_SIZE);
        ylabel(YLABEL, 'FontSize', AXIS_LABEL_FONT_SIZE);
        set(gca(),'FontSize', AXIS_TICKS_FONT_SIZE);
        % LEYENDA -------------------------------------------------
        if (exist('leyenda'))
                leyendaa = legend(graf(find(graf!=0)), leyenda{find(graf!=0)}, 
'Location',
'SouthOutside', 'Orientation', 'Horizontal');
                set(leyendaa, 'FontSize', LEGEND_FONT_SIZE);
        end%if
        % GRID ----------------------------------------------------
        grid on;

where the bold line is the one that produces the following error:

error: set: invalid handle (= -29.7374)

If it is commented everything works ok. 

Thanks in advance



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html



reply via email to

[Prev in Thread] Current Thread [Next in Thread]