xml2struct - Reference to non-existent field

조회 수: 2 (최근 30일)
Phil Newman
Phil Newman 2016년 6월 6일
편집: Phil Newman 2016년 6월 9일
I have a program which loads XML files into a Matlab structure, using the function
xml2struct([pathname filename])
which works really well.
This program is on a network drive "H:\" and a few folders of hierarchy. This drive is different to the one that has Matlab installed on it (C:\), and so when I run the program I 'change folder'. This all works fine.
I then save the exact same program to another drive, "E:\" with a similar (but different) amount of folder heirarchy, and no spaces in the path name.
I run the program and open the XML file (which is in the same location as previously, and on a different network drive). However, this does not run correctly; I have the error message "Reference to non-existent field 'RESULTS'" where RESULTS is a structure field that I am looking for.
I then look at the result of xml2struct, and find that the entries have been stored as 'children' which is different to how it stored them when working on the H:\ drive (they were stored as another structure hierarchy).
I have tried 'add path' and 'change folder' when running from new, but with the same error.
At no time in the code do I change directory, set path, or change path.
This is most bizzare, as it is the same program, same XML file, same code, but different network drive.
Can someone help explain why this might be occuring and how I can prevent it?

채택된 답변

Phil Newman
Phil Newman 2016년 6월 9일
편집: Phil Newman 2016년 6월 9일
Sorted it - I needed to point to a locally stored copy of the function by using addpath(genpath([pathname])). I tried doing this with the function stored at C:\Program Files\MATLAB\2015b\toolbox\bioinfo\biodemos but this didn't work.
I guess the function needs to be stored on the same drive as the program in order for it to work. addpath still needs to be used.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Search Path에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by