How to enter a numeric matrix published on the web page https://esc113.blogspot.com/2022/11/data.html
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I found how to enter a number matrix posted on the web page https://esc113.blogspot.com/2022/11/data.html.
See my code:
url = 'https://esc113.blogspot.com/2022/11/data.html';
a= webread(url);
b= extractHTMLText(a);
fID=fopen("abc.txt",'wt');
fprintf(fID,"%s",b);
fclose(fID);
fID=fopen("abc.txt",'rt');
tline = fgets(fID);
tline = fgets(fID);
tline = fgets(fID);
tline = fgets(fID);
for i=1:20
tline = fgets(fID);
A(i,:)=sscanf(tline,'%g');
end
A
But I think my solution is to mach complicated and not universal.
Can somebody show me shorter solution?
Thank you.
0 comentarios
Respuestas (1)
Sarthak
el 20 de Mzo. de 2023
Hi Vasiliy,
MATLAB offers inbuilt functions for text parsing and extractions. You can find elements from the html tree of your webpage.
url = 'https://esc113.blogspot.com/2022/11/data.html';
a= webread(url);
% Generate HTML tree
tree = htmlTree(a)
% Find required element using css selectors
element = findElement(tree, '.post-body');
% Extract text from the element
str = extractHTMLText(element);
You can also refer to the following documentation.
0 comentarios
Ver también
Categorías
Más información sobre Get Started with MATLAB en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!