How to rectify the "Improper index matrix reference" error in my coding for two dimensional data extraction from MATLAB Figure?
Mostra commenti meno recenti
I am trying to extract arrays of two dimensional data from the MATLAB figure file named "NF power_Aulayers_etch_glass-by-glass_xz" as attached. But, when I run the code, it doesn't extract the data, rather it shows "Improper index matrix reference" error message. So, how do I resolve the error and extract arrays of two dimensional data from the figure?
Note: I am using MATLAB R2014a.
Kindly help me to use the following code in MATLAB R2014a.
fig = openfig('NF power_Aulayers_etch_glass-by-glass_xz.fig');
Extracted_data = findobj(fig,'-property','XData','-property','YData','-property','Zdata');
x = Extracted_data(1).XData;
y = Extracted_data(1).YData;
z = Extracted_data(1).ZData;
1 Commento
Fangjun Jiang
il 11 Ago 2021
I ran the code in R2014b. No problem.
Risposte (1)
A lot of graphics stuff changed between R2014a/b. When you run findobj() in the older versions, the result Extracted_data is a handle in the form of a number (literally numeric class). In the later versions, it's a proper graphics object.
In R2009b:
>> class(Extracted_data)
ans =
double
in R2019b:
>> class(Extracted_data)
ans =
'matlab.graphics.chart.primitive.Surface'
Both of these are correct and usable with the conventions of their own era. The obvious thing to note is that you can't use dot indexing on a numeric scalar. Instead, you'd use get()/set() to access the obj it references. Since they're expecting that number to be a handle, they'll know what it means contextually.
x = get(Extracted_data,'XData');
y = get(Extracted_data,'YData');
z = get(Extracted_data,'ZData');
IDK that I explained that exactly right, but it's probably close enough.
2 Commenti
M M Shaky
il 27 Ago 2021
DGM
il 27 Ago 2021
fig = openfig('NF power_Aulayers_etch_glass-by-glass_xz.fig');
Extracted_data = findobj(fig,'-property','XData','-property','YData','-property','Zdata');
x = get(Extracted_data,'XData');
y = get(Extracted_data,'YData');
z = get(Extracted_data,'ZData');
...
Categorie
Scopri di più su Creating, Deleting, and Querying Graphics Objects in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!