How can I limit the load function?
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello, I am evaluating some external lists in Matlab. For this I import the signals with load('voyager_output_real.dat'); Etc. Since one signal only contains 1249 values, I am looking for a solution to limit all imported signals to 1249 values when loading. How can I do this quickly and easily?
I need that limit for the better view of plot. Thanks
My Code:
c
lose all;
clear all;
load('voyager_output_real.dat'); %10000 Values
load('voyager_signal_ideal.mat'); %Only 1249 Values
figure;
plot(voyager_output_real,'b-','linewidth',2);
hold on;
plot(voyager_signal_ideal,'r-','linewidth',2);
grid;
ylabel('Skalierungsfaktor');
xlabel('Samples');
0 Commenti
Risposte (2)
Star Strider
il 13 Ago 2022
I am not certain what you want, however one option is to Load List of Variables into Structure Array You can then limit the values.
Example —
x = 0:9999;
y = sin(2*pi*x/1000);
figure
plot(x, y)
grid
xline(1249,'--r')
save('test1.mat', 'x', 'y')
LD = load('test1.mat')
xv = LD.x(1:1249);
yv = LD.y(1:1249);
figure
plot(xv, yv)
grid
xlim([min(xv) max(xv)])
Experiment to get the result you want.
.
2 Commenti
Star Strider
il 13 Ago 2022
I understand that, however I do not have those data to experiment with.
My code example loads the entire record, then assigns only the range of interest to the data vectors. You can then specifically clear the ‘LD’ variables if you want to. (I did not see any specific reason to do that.) The ‘xv’ and ‘yv’ variables (in my code example) will remain in the workspace.
I am not certain that you can use load with the .dat files, since I have no idea what is in them. I would still load them into a structure and then deal with them there.
Walter Roberson
il 13 Ago 2022
In some cases, you can use matfile to access parts of a variable without loading the entire variable.
0 Commenti
Vedere anche
Categorie
Scopri di più su Annotations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!