How to extract data from a MATLAB figure containing multiple line plots and save it in a file?
36 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am working on the simulations of a BSIM3 type MOSFET model and as a result I need to extract data from a plot which shows the relationship between Ids(drain-source current, in the figure Y-axis; Iprobe1.i) and Vds(drain-source voltage, in the figure X-axis; VD) at increasing levels of gate voltage VG (say at VG=4V,6V,8V...)each represented by a different color. Please ignore the legend beside the plot which shows the value for VG as 0V, 1V etc since they are wrong and misguiding because of maybe improper operation of the TADS interface that I am using for connecting Advanced Design System (my original environment for simulation) and MATLAB.
I have seen examples of data extraction from 2 or 3 line plots maximum but never for multiple line plots and I have no idea how to approach this issue since I even want the VG value to be accounted for. (For eg: at VG=say 4V, I want a list of x and y values and similarly for VG=6V and so on). I have attached the MATLAB figure with this file, kindly help me out and reach out for further details.
0 Kommentare
Antworten (1)
William Rose
am 23 Apr. 2024
2 Kommentare
William Rose
am 23 Apr. 2024
When I open the file, I get seven error messages. I assume these are due to the imterface that does not work. Please post a figure that can be opened without errors.
The plot has twelve lines with legend 'VG=0;;', twelve lines with legend 'VG=1;;', and twelve lines with legend 'VG=2;;'.. THere are no lines with legend VG=4 or VG=6.
Here are commands to extract data from this figure.
filespec='Idsvs_Vdplot.fig';
fig=openfig(filespec);
axObjs = fig.Children;
lgd=axObjs(21);
numLeg=length(lgd.String);
ax1=axObjs(22);
dataObjs = ax1.Children;
numLines=length(dataObjs);
dataLen=zeros(numLines,1);
To get the x,y data from line 4, do
x4=dataObjs(4).XData; y4=dataObjs(4).YData;
To find out how many x,y pairs are on each line, do this:
dataLen=zeros(numLines,1);
for i=1:numLines
line=dataObjs(i);
dataLen(i)=length(line.XData);
end
If all lines have the same number of pairs, then you can make an array for the x data and an array for the y data. The number of columns in each array equals the number of lines on the plot. The number of rows equals the number of x,y pairs on each line.
xData=zeros(dataLen(1),numLines);
yData=zeros(dataLen(1),numLines);
Next: Put the x data into array xData, and put the y data into array yData:
for j=1:numLines
xData(:,j)=dataObjs(j).XData;
yData(:,j)=dataObjs(j).YData;
end
Plot the data from line 5:
plot(xData(:,5),yData(:,5),'-r');
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!