Trying to make a code that tells the weather

6 visualizaciones (últimos 30 días)
Rainaire Hansford
Rainaire Hansford el 16 de Sept. de 2021
Respondida: Image Analyst el 17 de Sept. de 2021
So I am trying to creat a code(s) that would tell the weather. I would like the code to speak the temperture value. I have the speech code just need to figure out the code for the weather.

Respuestas (2)

the cyclist
the cyclist el 16 de Sept. de 2021
You should be able to access a weather API (e.g. this free one), using the webread function.

Image Analyst
Image Analyst el 17 de Sept. de 2021
Some of the worlds smartest scientists have been using the worlds largest and fastest super computers for decades trying to do the same thing.
Actually I used to live in San Diego, which has been proven to have the most uniform temperature of any city in the world. Once the newspaper tried to see which of the 3 local TV stations was best at predicting the next day's weather. So they ran the "contest" for 3 months and one of them was most accurate but they said that even that TV station was not as accurate as if they'd just simply said "the weather tomorrow will be exactly the same as today". So if you live in or want to predict weather in San Diego just look up today or yesterday's temperature from the NOAA web site and make that your prediction for tomorrow. I know what it will be : 74 degrees F, because virtually every day of the year is 74 in San Diego. Go ahead and check it.
Once you have that you can use text to speech:
% Program to do text to speech. Works only with Windows Operating System.
% Get user's sentence
userPrompt = 'What do you want the computer to say?';
titleBar = 'Text to Speech';
defaultString = 'Hello World! MATLAB is an awesome program!';
caUserInput = inputdlg(userPrompt, titleBar, 1, {defaultString});
if isempty(caUserInput)
return;
end % Bail out if they clicked Cancel.
caUserInput = char(caUserInput); % Convert from cell to string.
% Instantiate the .NET assembly that will to the talking.
NET.addAssembly('System.Speech');
obj = System.Speech.Synthesis.SpeechSynthesizer;
% voiceCollection = obj.GetInstalledVoices() % Get list of all voices installed on the system.
% methods(voiceCollection) % See what it can do.
% Set the volume.
obj.Volume = 100;
% Here is the line of code that actually does the talking:
Speak(obj, caUserInput);
%==========================================================================
% Below is the mac version, from Walter Roberson
% userPrompt = 'What do you want the computer to say?';
% titleBar = 'Text to Speech';
% defaultString = 'Hello World! MATLAB is an awesome program!';
% caUserInput = inputdlg(userPrompt, titleBar, 1, {defaultString});
% if isempty(caUserInput)
% return;
% end; % Bail out if they clicked Cancel.
% caUserInput = char(caUserInput); % Convert from cell to string.
%
% system( sprintf('say "%s"', caUserInput) )

Categorías

Más información sobre Weather and Atmospheric Science en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by