Clear Filters
Clear Filters

Hello, I need a help , In Matlab how can I plot a graph from an excel data in real time ?

1 view (last 30 days)
data = xlsread('data.xls');
column_data = data(:, 1); % replace 1 with the column number you want to plot
figure;
ax = axes;
plot(ax, column_data);
xlim(ax, [0, length(column_data)]);
xlabel(ax, 'Time');
ylabel(ax, 'Data');
while true
% Read the latest data from the Excel file
data = xlsread('data.xls');
% Extract the latest data that you want to plot
new_data = data(:, 1); % replace1 with the column number you want to plot
% Append the new data to the existing data
column_data = [column_data; new_data];
% Update the plot with the new data
plot(ax, column_data);
% Pause for a short amount of time to allow new data to be generated
pause(0.01);
end

Answers (0)

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!