How can I read value from a json file and use it in the plot function?
Show older comments
Hello,
I would like to read a value from json file and use these values in the plot function.
So I did some resarch and realized that there is a lib named "loadjson" and I've added into my MATLAB. But I can't read values from my json file and cannot find a solution in MATLAB answers for it.
I'm kinda new at MATLAB and I need a bit of help :)
Thanks in advance.
The output of my json but I cannot see the values. I would like to read Location's values (locationX and locationY)

My JSON file:
"Location": [
{
"id": "0b5965e5-c509-4522-a525-8ef5a49dadaf",
"measureId": "5a6e9b79-dbb1-4482-acc1-d538f68ef01f",
"locationX": 0.9039769252518151,
"locationY": 0.2640594070404616,
"createdAt": "06-01-2021 19:38:44"
},
{
"id": "18714a2f-a8b3-4dc6-8a5b-114497fa9671",
"measureId": "671f52bc-a066-494a-9dce-6e9ccfac6c1d",
"locationX": 1.5592001730078755,
"locationY": 0.5207689756815629,
"createdAt": "06-01-2021 19:35:24"
},
My MATLAB code:
% Setting my image and related params
img = imread('C:/plan/plan.jpg');
imshow(img)
min_x = 0;
max_x = 7;
min_y = 0;
max_y = 3;
imagesc([min_x max_x], [min_y max_y], img);
% Load json file
data = loadjson('C:/data/default.json');
disp(data)
% I want to use these values into plot function.
hold on;
plot(x, y, 'ro', 'MarkerSize', 5);
Accepted Answer
More Answers (0)
Categories
Find more on JSON Format in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!