Get data out of figure file to combine with other dataset

조회 수: 6 (최근 30일)
Steen
Steen 2022년 10월 14일
이동: Walter Roberson 2022년 11월 9일
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
Steen
Steen 2022년 10월 14일
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 2022년 10월 14일
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

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2022년 10월 20일
이동: Walter Roberson 2022년 11월 9일
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
Steen
Steen 2022년 10월 25일
이동: Walter Roberson 2022년 11월 9일
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 2022년 11월 4일
이동: Walter Roberson 2022년 11월 9일
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;

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by