how to comment on ploting data in graph?

14 views (last 30 days)
Hi all;
i want to plot these two series of data and just nominate or comment two valuse from below series of data in ploting graph.
for example i want to give comment or name to 789 as required value in graph or 500 name as critical value.
solar radiation=[456 789 999 334 556 778 456 234 545 343 300 400 500 600 345]
heat gain=[456 789 765 345 234 654 768 979 567 456 678 453 867 989 234 ]
i will be very thankful .
thanks
  2 Comments
Ameer Hamza
Ameer Hamza on 22 Oct 2020
The two vectors you have written have different lengths.

Sign in to comment.

Accepted Answer

Ameer Hamza
Ameer Hamza on 22 Oct 2020
You can do something like this
solar_radiation=[456 789 999 334 556 778 456 234 545 343 300 400 500 600 345];
heat_gain=[456 789 765 345 234 654 768 979 567 456 678 453 867 989 234];
ax = axes();
hold on
p1 = plot(solar_radiation, heat_gain);
p2 = plot(500, heat_gain(solar_radiation==500), '.', 'MarkerSize', 50, 'DisplayName', 'Required Value');
p3 = plot(789, heat_gain(solar_radiation==789), '.', 'MarkerSize', 50, 'DisplayName', 'Critical Value');
legend([p2 p3])
  2 Comments
Engineer Batoor khan mummand
thank you so much dear...
i want to import average of each day solar radiation from attached excel file but average of those solar radiation values which is greather than 200 for each day .
i will be very thankful dear.
thanks
Image Analyst
Image Analyst on 22 Oct 2020
Edited: Image Analyst on 22 Oct 2020
Here it is again.
[numbers, strings, rawData] = xlsread('hiii.xlsx');
daysOfWeek = strings(2:end, 2);
% Threshold at 200
goodIndexes = numbers >= 200;
% Extract only those elements above 200.
numbers = numbers(goodIndexes);
daysOfWeek = daysOfWeek(goodIndexes);
% Label each individual day.
sequentialDays = ones(length(daysOfWeek), 1);
for k = 2 : length(sequentialDays)
if ~strcmpi(daysOfWeek{k}, daysOfWeek{k-1})
% It's not the same as the prior day so we're starting a new day.
sequentialDays(k:end) = sequentialDays(k-1) + 1;
end
end
% Get the averages over any and all hours of each day.
dailyAverages = splitapply(@mean, numbers, sequentialDays);
plot(dailyAverages, 'b-', 'LineWidth', 2);
title('Daily Average of Solar Radiation', 'FontSize', 18);
xlabel('Day', 'FontSize', 18);
ylabel('Average over the Day', 'FontSize', 18);
grid on;
% Smooth the daily averages
smoothedAverages = movmean(dailyAverages, 45);
hold on;
plot(smoothedAverages, 'r-', 'LineWidth', 4);
legend('Data >= 200', 'Smoothed');
g = gcf;
g.WindowState = 'maximized';
fprintf('Done running %s.m ...\n', mfilename);

Sign in to comment.

More Answers (0)

Products


Release

R2017a

Community Treasure Hunt

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

Start Hunting!