フィルターのクリア

How to extract data from a MATLAB figure containing multiple line plots and save it in a file?

27 ビュー (過去 30 日間)
Shreeja
Shreeja 2024 年 4 月 22 日
コメント済み: Shreeja 2024 年 4 月 23 日
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.

回答 (1 件)

William Rose
William Rose 2024 年 4 月 23 日
  2 件のコメント
William Rose
William Rose 2024 年 4 月 23 日
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');
Shreeja
Shreeja 2024 年 4 月 23 日
Hi, thanks for your answer and help.
Yes the errors you see are because of the TADS interface, because in my original simulating environment on ADS I can see all these lines attributed to VG=4V,6V and so on from the bottom to the top. I have the feeling the interface in itself is pulling the wrong data and hence we see multiple lines for VG=0V, 1V and so on. I tried it again afresh today but it still doesnt work and shows the same plot with these values.

サインインしてコメントする。

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by