MATLAB Answers

0

How to i extract data from my plot into excel?

Asked by Akash Menon on 19 Oct 2018
Latest activity Commented on by Akash Menon on 22 Oct 2018
Hi there community!
So I have a signal now that I've been struggling to figure out how to extract the data from the plot and save it to excel. I recently asked a question about how to plot 8640 data points across 86400 seconds. (there were 8640 measurements taken in a day and I had to plot it across the whole day). I need to now create a signal out of the plotted data to use on Simulink.
The signal that I extract from the plot must have 86400 y values and the x values must go from 0-86400 (with 1 second intervals). How do I go about doing this? I'm not an expert with matlab so if it could be dumbed down a bit that'd help. Or if there's a way to directly put it into the signal builder block in Simulink.
Thanks very much!

  2 Comments

if you have the data in hand why would you extract from the plot??
I have 8640 datapoints but the range of measurement is 86400 seconds so I wanted to interpolate the values in-between.
%%Plotting the measured power signals
% Reading excel data
mydata=xlsread('pow_demand_test.xlsx');
% Adjusting the x-axis vector (86400 datapoints)
%t = days(1);
t=1:8640;
t=t*10;
% Plot 1
plot(t,mydata)
%%Interpolation of the 8640 datapoints over 86400 seconds
x1=linspace(10,86400,8640);
x2=linspace(1,86400,86400);
data2 = interp1(x1,mydata,x2);
data3=data2';
%%Plot 2
t2=1:86400;
plot(t2,data3)
Managed to do it so hope it helps others! (I used the data3 array stored in the workspace to move the data to excel then I imported that into Signal builder to build a signal out of it- the plots are only for representative purposes- the interpolated data is stored in 'data3' )

Sign in to comment.

Products


Release

R2018b

0 Answers