MATLAB: Using google on matlab web browser

google

So I am trying to use the web browser for matlab using so far I have this code.
url = 'www.google.com';
web(url)
I'm to make a code where I would type some thing to sereach (Like you would with google) but using my matlab code and matlab browser.
Is there a way?

Best Answer

You need to generate the complete url from matlab and then pass that to web(url). After a brief testing, the format for google search is
url = ['www.google.com/search?q=' search_target];
in search target, different words should be separated by '+', as this is how google works. You can check that yourself by searching something in google and looking at the url
Examples:
This only looks for cats:
search_target = 'cats';
url = ['www.google.com/search?q=' search_target];
web(url)
This looks for food recommendations for cats:
search_target = 'food+recomendations+for+cats';
url = ['www.google.com/search?q=' search_target];
web(url)
About introducing the "+" between words, you will need to distinguish between the different words that are part of the question and then add that between them.
Related Question