Editing Text Strings through Looping
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello Matlab community,
I am new to Matlab programming and have a question surrounding editing text strings through looping.
I am working with API datasearch tool and would like to loop through various text strings. How would I go about doing this?
For example, below is standard Matlab API code for a nonexistant website example. In this example I am telling Matlab to collect from this website a specific data array with code=587. Then I move onto the next code=612.
api = 'http://examplewebsite.com/api'
url = [api 'max=1000/type=fl/sign=xy/code=587/st=87']
S = webread(url)
api = 'http://examplewebsite.com/api'
url = [api 'max=1000/type=fl/sign=xy/code=612/st=87']
S = webread(url)
If I had a list of codes I wanted Matlab to collect data for, such as
d = [587 612 876 296 137 635 591]
Could I create a loop where all I change to the string 'max=1000/type=fl/sign=xy/code=587/st=87' is just the code=587 to code=612...up to 591?
The goal would be to get 7 different S matrices corresponding to the 7 codes in one step.
Thank you,
James
0 commentaires
Réponses (1)
Geoff Hayes
le 10 Nov 2020
for code = [587 612 876 296 137 635 591]
url = sprintf('http://examplewebsite.com/apimax=1000/type=fl/sign=xy/code=%d/st=87', code)
S = webread(url);
% save S to larger matrix or cell array
end
0 commentaires
Voir également
Catégories
En savoir plus sur Data Type Identification dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!