How to replace a column in a text file with time and plot a graph from it?

1 visualizzazione (ultimi 30 giorni)
The first column shows the frequency of data aquisition, which is 1000 hz. But I need to replace the first column of the text file with time, starting with 0 secs, then 0.0001s till 60s. it is then used to plot a graph of data points, where the 2nd and 3rd columns are outputs. The picture of text file is attached.
Any help is appreciated.
I tried with the following command but it didnt work and took forever.
data = load('test1.txt');
data(:, 1) = 0:0.0001:60000;

Risposta accettata

KALYAN ACHARJYA
KALYAN ACHARJYA il 4 Mar 2020
Modificato: KALYAN ACHARJYA il 4 Mar 2020
Please note: It should be column vector
data = load('test1.txt');
data(:, 1) =[0:0.0001:60000]';
  5 Commenti
KALYAN ACHARJYA
KALYAN ACHARJYA il 4 Mar 2020
Its simple
>> length(data(:,1))
ans =
62000
>> length(0:0.0001:60000)
ans =
600000001
Make the array 0:0.0001:60000 having the same length as length(data(:,1)), which is 62000, or use
linspace(0,60000,62000); % set the step size as requred

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by