Since you are new, let us show you how Trendy works.

Close-button

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

  • Created by: Aurelien Queffurust
  • Latest result: Plot created
  • Created on: 04 Jun 2012
  • Liked: 3 times

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')



%% 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) ' °C ',...
' vs French TMW office -> ' num2str(mean_TMW,3) ' °C' 10,...
'Biggest difference : ' int2str(biggest_ecart) '°C on ' was  ' (' int2str(data1724(loc,1)) ' °C at Corbières)'])
set(r,'interpreter','none')
set(gca,'ygrid','on','tickdir','out')
datetick

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

Add Tags


6 comments

Aurelien Queffurust about 2 years ago

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/

Aurelien Queffurust about 2 years ago

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/

Aurelien Queffurust about 2 years ago

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

Aurelien Queffurust almost 2 years ago

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

Aurelien Queffurust almost 2 years ago

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/

Aurelien Queffurust 10 months ago

The second subplot now displays the last 30 records