How to save entire MATLAB workspace as a JSON file?

조회 수: 30 (최근 30일)
AluminiumMan
AluminiumMan 2024년 5월 29일
댓글: AluminiumMan 2024년 6월 2일
Hi everyone, I need to export my MATLAB workspace as a JSON file.
From what I can see, the standard save command wouldn't be useful here.
And the jsonencode help doesn't tell you how to save the entire workspace as a JSON file:
Any help on how to achieve this would be much appreciated

답변 (1개)

the cyclist
the cyclist 2024년 5월 29일
There is no built-in way to do this in MATLAB, and it strikes me as quite difficult to do in a way that is general enough to manage any workspace.
I think the rough outline of how to do this would be
  • use the who command to identify the variables in the workspace
  • make a structure with fields for each variable
  • encode the structure into JSON with jsonencode
One challenge here is the data types that might need to be converted somehow to fit in the MATLAB structure. Things that come to mind are anonymous function handles and MATLAB objects.
All in all, it seems like a daunting task. What are you trying to do with the JSON object that you create? I wonder if you might be falling into the XY Problem.
  댓글 수: 1
AluminiumMan
AluminiumMan 2024년 6월 2일
Hi, thanks for getting back to me. I want to export my workspace into Tableau and JSON is the only file that seems to be compatable from MATLAB to Tableau

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 JSON Format에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by