Save vector to class properties
Mostrar comentarios más antiguos
Greetings,
I am trying to build a class that would extract information from .csv files and save these information to the properties of the class. Attached is the example of the file.
Here are my code:
classdef post_processing
properties
data_folder = 'path\path'
filename
time
voltage
norm_voltage
record_length
state_level_high
state_level_low
end
methods
function extract_info(obj)
addpath(obj.data_folder);
filename = 'test.csv';
data = readmatrix(filename);
horizontal_offset = data(6,2); %seconds
sample_interval = data(2,2);%seconds
record_length = data(1,2); %points
time = data(:,4)-horizontal_offset; %seconds
voltage = data(:,5); %volt
norm_voltage = data(:,5)/max(data(:,5));%arb. units
obj.time = time;
obj.voltage = voltage;
obj.norm_voltage = norm_voltage;
obj.record_length = record_length;
end
end
end
I called my script:
test = post_processing;
extract_info(test);
test
give output

I do not know why my properties are not updated when I called my extract_info function.
Thanks for the help.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Octave en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!