Get data out of figure file to combine with other dataset

3 views (last 30 days)
Hi
I am new to Matlab
I want to get data out of .Fig file and then combine the data from .Fig file with data from spreadsheet to make a combined plot
I have large scale data 3600000 linies, but to make it simple. I have attachted a small .Fig file and a small spreadsheet.
Please help me to understand the steps I have to follow to combine the data.
  3 Comments
Steen
Steen on 14 Oct 2022
My bad. The data are the same. I have attached new files. I have also added a visual process of the data treatment.
The reason way. I have two different input data, are because I have two different meassurement equipment attached the meassure my system ( one meassurement cant meassure all data)
Walter Roberson
Walter Roberson on 14 Oct 2022
It isn't clear why you are not just doing
figfile = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1156208/Fig%20import%20test%20rev1.fig';
datafile = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1156213/Values%20to%20combine%20with%20Fig.xlsx';
tempfile = tempname() + ".fig";
fig = openfig(websave(tempfile, figfile));
T = readtable(datafile);
hold on
t = T.time;
P = T.Properties.VariableNames(2:end);
for K = 1 : length(P)
fn = P{K};
plot(t, T.(fn), 'DisplayName', fn);
end
hold off
set(gcf, 'visible', 'on')
legend show

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 20 Oct 2022
Moved: Walter Roberson on 9 Nov 2022
The websave layer is there in order to permit me to reference the .fig file you attached. For local use,
figfile = 'Fig import test rev1.fig';
datafile = 'Values to combine Fig.xlsx';
fig = openfig(figfile);
T = readtable(datafile);
hold on
t = T.time;
P = T.Properties.VariableNames(2:end);
for K = 1 : length(P)
fn = P{K};
plot(t, T.(fn), 'DisplayName', fn);
end
hold off
set(gcf, 'visible', 'on')
legend show
  5 Comments
Steen
Steen on 25 Oct 2022
Moved: Walter Roberson on 9 Nov 2022
Hi Walter
I had succes today. But I had to modify you code. And also remove .txt filer header
Remove header
Original header
If I used your code
figfile = 'IBox 100-100 - Copy.fig';
datafile = 'Copy_of_V164_Backup_KK_Con_Test1_Step1_100_100_Rev1_short version_rev5.txt';
fig = openfig(figfile);
T = readtable(datafile, 'VariableNames', ["TIME","VFD DC IN V","VFD AC OUT V"]);
hold on
t = T.time;
P = T.Properties.VariableNames(2:end);
for K = 1 : length(P)
fn = P{K};
plot(t, T.(fn), 'DisplayName', fn);
end
hold off
set(gcf, 'visible', 'on')
legend show
I get this error
>> clear
>> extract_data_from_figures_13
Error using readtable
Ambiguous parameter name: VariableNames.
Error in extract_data_from_figures_13 (line 4)
T = readtable(datafile, 'VariableNames', ["TIME","VFD DC IN V","VFD AC OUT V"]);
But if I change
T = readtable(datafile, 'VariableNames', ["TIME","VFD DC IN V","VFD AC OUT V"]);
to
T = readtable(datafile,'Format','auto');
it works fine
Can you advice me if the code change are ok and how to get the code to ignore the heater
Walter Roberson
Walter Roberson on 4 Nov 2022
Moved: Walter Roberson on 9 Nov 2022
T = readtable(datafile);
T.Properties.VariableNames = ["TIME","VFD DC IN V","VFD AC OUT V"];
and you will need to change
t = T.time;
to
t = T.TIME;

Sign in to comment.

Categories

Find more on Test and Measurement in Help Center and File Exchange

Tags

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!