i want to read a url in MATLAB through webread function

9 ビュー (過去 30 日間)
Muhammad Hussain
Muhammad Hussain 2023 年 2 月 15 日
コメント済み: Muhammad Hussain 2023 年 2 月 16 日
i am trying to read url of AEMO(https://aemo.com.au/Energy-systems/Electricity/National-Electricity-Market-NEM/Data-NEM/Data-Dashboard-NEM) in a csv format of Price(Spot Price ($/MWh) ) and Demand(Scheduled Demand (MW) ) columns. i tried different ways to read it through webread function in MATALB with url and query parameters(query name and query values). i need guidance how to read these columns through webread funtion.
  1 件のコメント
Muhammad Hussain
Muhammad Hussain 2023 年 2 月 16 日
thanks alot Askic V for your guidance, this will definetly solve the issue i was facing.

サインインしてコメントする。

採用された回答

Askic V
Askic V 2023 年 2 月 15 日
編集済み: Askic V 2023 年 2 月 15 日
You need actually to use function webwrite, so you can write a POST request to the web server, and then to examine the response.
csv file is actually generated only when user click on the symbol for download button and this file is generated inside the browser itself.
So, your best bet is to obtain the data and then process it somehow.
What I managed to do is the following:
%%
clear
clc
close all
% url for POST request
url = 'https://visualisations.aemo.com.au/aemo/apps/api/report/5MIN';
% body for POST request
body = '{"timeScale": ["30MIN"]}';
% make response
response = webwrite(url, body);
% processing results
resp_period_type = {response.x5MIN.PERIODTYPE};
ind_actual = find(strcmp(resp_period_type,'ACTUAL'));
ind_forecast = find(strcmp(resp_period_type,'FORECAST'));
% datetime
resp_date_time = {response.x5MIN.SETTLEMENTDATE};
date_time_arr = datetime(strrep(resp_date_time,'T',' '),'InputFormat','yyyy-MM-dd HH:mm:ss');
resp_date_time_actual = date_time_arr(ind_actual);
resp_date_time_forecast = date_time_arr(ind_forecast);
% prices
resp_spot_price = [response.x5MIN.RRP];
resp_spot_price_actual = resp_spot_price(ind_actual);
resp_spot_price_forecast = resp_spot_price(ind_forecast);
% demand
resp_sch_demand = [response.x5MIN.TOTALDEMAND];
resp_sch_demand_actual = resp_sch_demand(ind_actual);
resp_sch_demand_forecast = resp_sch_demand(ind_forecast);
subplot(211)
plot(resp_date_time_actual, resp_spot_price_actual)
title('Actual')
subplot(212)
plot(resp_date_time_forecast, resp_spot_price_forecast)
title('Forecast')
I believe this code will be useful to you. This is the data that is returned, I have randomly checked 2 or three values at particular date and time and it seems to be a match to those values in the csv file, even though more data is returned in ths request.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWeb Services についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by