Get data out of figure file to combine with other dataset
3 views (last 30 days)
Show older comments
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
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
Answers (1)
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
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;
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!