How to enter a numeric matrix published on the web page https://esc113.blogspot.com/2022/11/data.html
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Sarthak
2023 年 3 月 20 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!