The Trendy application is being retired in the new year. The new web application, ThingSpeak, offers similar functionality. We recommend that active Trendy users who are looking to create new trends use ThingSpeak. To begin collecting your data in ThingSpeak, please read the tutorial : ThingSpeak for Trendy users. Although Trendy no longer allows the creation of new trends, the application will still remain accessible until January 13, 2016. Until that date, you can view your current trends and download your data. After that date, your data will no longer be accessible. Thanks for using Trendy and we encourage you to check out ThingSpeak.

Close-button

MathWorks should have an office in my village ... !!

The idea is to compare everyday at 1:00 PM the temperature between my village Corbières (04220) in the South of France (near Marseille) and Meudon (French MathWorks Office which is near Paris)

After a few months , taking the decision to build a new office at Corbières should be easy ;-)

The information is gathered from Meteociel : http://www.meteociel.fr/previsions/1599/corbieres.htm and http://www.meteociel.fr/previsions/33209/meudon.htm. They use the American system Global Forecast System which is a global numerical weather prediction computer model.

See also : mon blog MATLAB pour les geeks!

Plot Image
% Reason why MathWorks should have an office in my village
% remove nan


study_days = fix(time1724(end)-time1724(1));
Seconds   = round(1                 );
Minutes   = round(60     * Seconds  );
Hours     = round(60     * Minutes  );
Days      = round(24     * Hours    );
Weeks     = round(7      * Days     );
Months    = round(30.471 * Days     );
Years     = round(365.26 * Days     );
Centuries = round(100    * Years    );
Millennia = round(10     * Centuries);

%% put these into an array, and define associated strings
units   = [Millennia, Centuries, Years, Months, Weeks, ...
    Days, Hours, Minutes, Seconds];

singles = {'millennium'; 'century'; 'year'; 'month'; ...
    'week'; 'day'; 'hour'; 'minute'; 'second'};

plurals = {'millennia' ; 'centuries'; 'years'; 'months'; ...
    'weeks'; 'days'; 'hours'; 'minutes'; 'seconds'};


secs = round(86400*study_days);

%% parse second argument
short = true;


%% pre-allocate appropriate output-type
numstrings = numel(secs);
if (numstrings > 1)
    out = cell(size(secs));
end

%% build (all) output string(s)
for jj = 1:numstrings
    
    % initialize nested loop
    secsj   = secs(jj);
    counter = 0;
    if short
        string = 'About ';
    else
        string = '';
    end
    
    % possibly quick exit
    if (secsj < 1)
        string = 'Less than one second.';
    end
    
    % build string for j-th amount of seconds
    for i = 1:length(units)
        
        % amount of this unit
        amount = fix(secsj/units(i));
        
        % include this unit in the output string
        if amount > 0
            
            % increase counter
            counter = counter + 1;
            
            % append (single or plural) unit of time to string
            if (amount > 1)
                string = [string, num2str(amount), ' ', plurals{i}];%#ok
            else
                string = [string, num2str(amount), ' ', singles{i}];%#ok
            end
            
            % Finish the string after two units if short format is requested
            if (counter > 1 && short), string = [string, '.']; break, end%#ok
            
            % determine whether the ending should be a period (.) or a comma (,)
            if (rem(secsj, units(i)) > 0)
                if short
                    ending = ' and ';
                else
                    ending = ', ';
                end
            else
                ending = '.';
            end
            string = [string, ending];%#ok
            
        end
        
        % subtract this step from given amount of seconds
        secsj = secsj - amount*units(i);
    end
    
    % insert in output cell, or set output string
    if numstrings > 1
        out{jj} = string;
    else
        out = string;
    end
end 
study_days = out(1:end-1);

%% first plot Fahrenheit (for US people)
%°F = (( 9 x °C ) / 5 ) + 32
fahreinheit_data = (9*data1724)/5+32;
y1min = min(min(fahreinheit_data));
y1max = max(max(fahreinheit_data));
subplot(2,1,1)
ylim([y1min(1)-1 y1max(1)+1])
ylabel('Temperature in Fahreinheit')
plot(time1724,fahreinheit_data(:,1),'color',[0 0.5 0],'displayname','Corbières')
hold on
plot(time1724,fahreinheit_data(:,2),'red','displayname','TMW')
datetick
ylabel('Fahreinheit')

title([study_days ' later : What about a TMW office in the South Of France? !'],'fontweight','bold','color','red')
set(gca,'fontweight','bold')
set(gca,'ygrid','on','tickdir','out')
legend('location','SouthWest')

hax = gca;
topcolor =  rand(3,1);%[1 0 0];    % red
bottomcolor = rand(3,1);% [0 1 0]; % green
lim = axis(hax); % return xlim and ylim
xdata1 = [lim(1) lim(2) lim(2) lim(1)];
ydata = [lim(3) lim(3) lim(4) lim(4)];
cdata(1,1,:) = bottomcolor;
cdata(1,2,:) = bottomcolor;
cdata(1,3,:) = topcolor;
cdata(1,4,:) = topcolor;

patch(xdata1,ydata,'k','Parent',hax,...
    'CData',cdata, ...
    'FaceColor','interp', ...
    'EdgeColor','none','FaceAlpha',.3);

%% DEGREES
subplot(2,1,2)
ylabel('Temperature in Degrees')

y1min = min(min(data1724));
y1max = max(max(data1724));

corbieres_temperatures= data1724(:,1);
paris_temperatures = data1724(:,2);




% find the number of times it was warmer in Paris
index_betteratParis = find(corbieres_temperatures<paris_temperatures);
fprintf('\n Only %d times higher in Paris: ',numel(index_betteratParis))
Paris_was= data1724(index_betteratParis,2)
corbieres_was= data1724(index_betteratParis,1)

latser = 30;
plot(time1724(end-latser :end),corbieres_temperatures(end-latser :end),'color',[0 .5 0],'LineWidth',2)
hold on 
plot(time1724(end-latser :end),paris_temperatures(end-latser :end),'red','LineWidth',2)
ylim([y1min(1)-2 y1max(1)+2])

 [biggest_ecart ,loc] = max(corbieres_temperatures-paris_temperatures);
high_temperature = max(data1724(loc,1))

was = datestr(time1724(loc),1);

% remove nan
corbieres_temperatures(isnan(corbieres_temperatures)) = [];
paris_temperatures(isnan(paris_temperatures)) = [];

mean_corb = mean(corbieres_temperatures);
mean_TMW = mean(paris_temperatures);
ylabel('Degrees')
xlabel('30 last temperatures')
r=title(['Mean Temperature : Corbieres -> ' num2str(mean_corb,3) ' \circC ',...
' vs French TMW office -> ' num2str(mean_TMW,3) ' \circC' 10,...
'Biggest difference : ' int2str(biggest_ecart) ' \circC on ' was  ' (' int2str(data1724(loc,1)) ' \circC at Corbieres)'])

set(gca,'ygrid','on','tickdir','out')

datetick

set(gcf,'color','yellow')


hax = gca;
topcolor =  rand(3,1);%[1 0 0];    % red
bottomcolor = rand(3,1);% [0 1 0]; % green
lim = axis(hax); % return xlim and ylim
xdata1 = [lim(1) lim(2) lim(2) lim(1)];
ydata = [lim(3) lim(3) lim(4) lim(4)];
cdata(1,1,:) = bottomcolor;
cdata(1,2,:) = bottomcolor;
cdata(1,3,:) = topcolor;
cdata(1,4,:) = topcolor;

patch(xdata1,ydata,'k','Parent',hax,...
    'CData',cdata, ...
    'FaceColor','interp', ...
    'EdgeColor','none','FaceAlpha',.3);

Tags:

Add Tags


9 comments

This plot has been quoted on the blog "MATLAB Central Release Notes – May 2012" : http://blogs.mathworks.com/community/2012/06/04/matlab-central-release-notes-may-2012/

This Trendy was also discussed on the blog "MATLAB Spoken Here"
Multipoint data gathering in Trendy:
http://blogs.mathworks.com/community/2012/06/18/multipoint-data-gathering-in-trendy/

If we look at the mean temperature, we can use the formula "Six degrees of separation" !!

In 4 months (121 days), it happened only 3 times that the temperature was higher in Paris ...

August 27th, 2012 :
This Trendy was again discussed on the blog "MATLAB Spoken Here" http://blogs.mathworks.com/community/2012/08/27/learn-about-matlab-plots-using-trendy/

The second subplot now displays the last 30 records

Improvements:
- New background color for ach subplot
- Degrees diplayed using Tex symbol : \circC

New record : 26 Jul 2015
31 degrees in my village Corbières versus 16 degrees only at Meudon! 15 degrees of difference