Does MATLAB have functionality similar to Mathematica's Import function to import html tables?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I'm trying to do in MATLAB the work that I previously did in Mathematica using its Import function to query a website, discover the available data elements and then grab whatever I needed. Mathematica's Import functionality includes what MATLAB's webread() does. For example, the MATLAB command
> data=webread("http://physics.nist.gov/PhysRefData/XrayMassCoef/ElemTab/z29.html")
does what Mathematica does using
In[1]:= Import["http://physics.nist.gov/PhysRefData/XrayMassCoef/ElemTab/z29.html", "Source"]
But with Mathematica I can also discover the available HTML elements:
In[2]:= Import["http://physics.nist.gov/PhysRefData/XrayMassCoef/ElemTab/z29.html", "Elements"]
Out[2]= {"Data", "FullData", "Hyperlinks", "ImageLinks", "Images", "Plaintext", "Source", "Title", "XMLObject"}
I have attached a pdf file in which I use Mathematica's Import to obtain the HTML elements listed previously. For example, to grab the table data in a format that is ready for use (i.e. with the HTML structure removed), I can do this:
In[3]:= Import["http://physics.nist.gov/PhysRefData/XrayMassCoef/ElemTab/z29.html","Data"][[1]]
Out[16]= {" Copper Z = 29 HTML table format", {"Energy", "\[Mu] / \[Rho]", "\[Mu] en / \[Rho]"}, {"(MeV)", "(cm 2 /g)", "(cm 2 /g)"}, {0.001, 10570., 10490.},{0.00104695, 9307., 9241.}, {0.0010961, 8242., 8186.}, {"L1", 0.0010961, 9347., 9282.}, {0.0015, 4418., 4393.}, {0.002, 2154., 2142.}, {0.003, 748.8, 743.}, {0.004, 347.3, 343.2}, {0.005, 189.9, 186.6}, {0.006, 115.6, 112.8}, {0.008, 52.55, 50.54}, {0.0089789, 38.29, 36.52}, {"K", 0.0089789, 278.4, 182.4}, {0.01, 215.9, 148.4}, {0.015, 74.05, 57.88}, {0.02, 33.79, 27.88}, {0.03, 10.92, 9.349}, {0.04, 4.862, 4.163}, {0.05, 2.613, 2.192}, {0.06, 1.593, 1.29}, {0.08, 0.763, 0.5581}, {0.1, 0.4584, 0.2949}, {0.15, 0.2217, 0.1027}, {0.2, 0.1559, 0.05781}, {0.3, 0.1119, 0.03617}, {0.4, 0.09413, 0.03121}, {0.5, 0.08362, 0.02933}, {0.6, 0.07625, 0.02826}, {0.8, 0.06605, 0.02681}, {1., 0.05901, 0.02562}, {1.25, 0.05261, 0.02428}, {1.5, 0.04803, 0.02316}, {2., 0.04205, 0.0216}, {3., 0.03599, 0.02023}, {4., 0.03318, 0.01989}, {5., 0.03177, 0.01998}, {6., 0.03108, 0.02027}, {8., 0.03074, 0.021}, {10., 0.03103, 0.02174}, {15., 0.03247, 0.02309}, {20., 0.03408, 0.02387}}
Is there anyway I could do this in MATLAB without writing code to parse the information returned by webread()?
Thanks,
Neil
Risposta accettata
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Data Import and Analysis in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!