9 views (last 30 days)
Show older comments
Shaymaa Tahhan on 22 Feb 2024
Answered: Voss on 22 Feb 2024
- intensity with lines.fig
Please I have tried alot with this code
open('spectrum.fig');
a = get(gca,'Children');
xdata = get(a, 'XData');
ydata = get(a, 'YData');
xdata1 = get(a(2), 'XData');
ydata1 = get(a(2), 'YData');
but it doesnt work correctly I just get the last line data?!
0 Comments Show -2 older commentsHide -2 older comments
Show -2 older commentsHide -2 older comments
Sign in to comment.
Sign in to answer this question.
Answers (1)
Voss on 22 Feb 2024
- intensity with lines.fig
f = openfig('intensity with lines.fig');
lines = findall(f,'Type','line')
lines =
10×1 Line array: Line Line Line Line Line Line Line Line Line Line
xdata = get(lines,'XData'); % xdata: 10x1 cell array, each cell contains 1 line's XData
ydata = get(lines,'YData'); % ydata: 10x1 cell array, each cell contains 1 line's YData
If you know that the lines XData/YData are all row vectors of the same size (which they are in this case), it may be convenienet to concatentate them into a single matrix:
xdata = vertcat(xdata{:})
xdata = 10×8192
1.0e-11 * -0.6250 -0.6248 -0.6247 -0.6245 -0.6244 -0.6242 -0.6241 -0.6239 -0.6238 -0.6236 -0.6235 -0.6233 -0.6232 -0.6230 -0.6229 -0.6227 -0.6226 -0.6224 -0.6223 -0.6221 -0.6219 -0.6218 -0.6216 -0.6215 -0.6213 -0.6212 -0.6210 -0.6209 -0.6207 -0.6206 -0.6250 -0.6248 -0.6247 -0.6245 -0.6244 -0.6242 -0.6241 -0.6239 -0.6238 -0.6236 -0.6235 -0.6233 -0.6232 -0.6230 -0.6229 -0.6227 -0.6226 -0.6224 -0.6223 -0.6221 -0.6219 -0.6218 -0.6216 -0.6215 -0.6213 -0.6212 -0.6210 -0.6209 -0.6207 -0.6206 -0.6250 -0.6248 -0.6247 -0.6245 -0.6244 -0.6242 -0.6241 -0.6239 -0.6238 -0.6236 -0.6235 -0.6233 -0.6232 -0.6230 -0.6229 -0.6227 -0.6226 -0.6224 -0.6223 -0.6221 -0.6219 -0.6218 -0.6216 -0.6215 -0.6213 -0.6212 -0.6210 -0.6209 -0.6207 -0.6206 -0.6250 -0.6248 -0.6247 -0.6245 -0.6244 -0.6242 -0.6241 -0.6239 -0.6238 -0.6236 -0.6235 -0.6233 -0.6232 -0.6230 -0.6229 -0.6227 -0.6226 -0.6224 -0.6223 -0.6221 -0.6219 -0.6218 -0.6216 -0.6215 -0.6213 -0.6212 -0.6210 -0.6209 -0.6207 -0.6206 -0.6250 -0.6248 -0.6247 -0.6245 -0.6244 -0.6242 -0.6241 -0.6239 -0.6238 -0.6236 -0.6235 -0.6233 -0.6232 -0.6230 -0.6229 -0.6227 -0.6226 -0.6224 -0.6223 -0.6221 -0.6219 -0.6218 -0.6216 -0.6215 -0.6213 -0.6212 -0.6210 -0.6209 -0.6207 -0.6206 -0.6250 -0.6248 -0.6247 -0.6245 -0.6244 -0.6242 -0.6241 -0.6239 -0.6238 -0.6236 -0.6235 -0.6233 -0.6232 -0.6230 -0.6229 -0.6227 -0.6226 -0.6224 -0.6223 -0.6221 -0.6219 -0.6218 -0.6216 -0.6215 -0.6213 -0.6212 -0.6210 -0.6209 -0.6207 -0.6206 -0.6250 -0.6248 -0.6247 -0.6245 -0.6244 -0.6242 -0.6241 -0.6239 -0.6238 -0.6236 -0.6235 -0.6233 -0.6232 -0.6230 -0.6229 -0.6227 -0.6226 -0.6224 -0.6223 -0.6221 -0.6219 -0.6218 -0.6216 -0.6215 -0.6213 -0.6212 -0.6210 -0.6209 -0.6207 -0.6206 -0.6250 -0.6248 -0.6247 -0.6245 -0.6244 -0.6242 -0.6241 -0.6239 -0.6238 -0.6236 -0.6235 -0.6233 -0.6232 -0.6230 -0.6229 -0.6227 -0.6226 -0.6224 -0.6223 -0.6221 -0.6219 -0.6218 -0.6216 -0.6215 -0.6213 -0.6212 -0.6210 -0.6209 -0.6207 -0.6206 -0.6250 -0.6248 -0.6247 -0.6245 -0.6244 -0.6242 -0.6241 -0.6239 -0.6238 -0.6236 -0.6235 -0.6233 -0.6232 -0.6230 -0.6229 -0.6227 -0.6226 -0.6224 -0.6223 -0.6221 -0.6219 -0.6218 -0.6216 -0.6215 -0.6213 -0.6212 -0.6210 -0.6209 -0.6207 -0.6206 -0.6250 -0.6248 -0.6247 -0.6245 -0.6244 -0.6242 -0.6241 -0.6239 -0.6238 -0.6236 -0.6235 -0.6233 -0.6232 -0.6230 -0.6229 -0.6227 -0.6226 -0.6224 -0.6223 -0.6221 -0.6219 -0.6218 -0.6216 -0.6215 -0.6213 -0.6212 -0.6210 -0.6209 -0.6207 -0.6206
ydata = vertcat(ydata{:})
ydata = 10×8192
1.0e+00 * 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
so that xdata(1,:) is the first line's XData, xdata(2,:) is the second line's XData, etc., etc.
0 Comments Show -2 older commentsHide -2 older comments
Show -2 older commentsHide -2 older comments
Sign in to comment.
Sign in to answer this question.
See Also
Categories
MATLABProgrammingProgramming Utilities
Find more on Programming Utilities in Help Center and File Exchange
Tags
- data import
- figure data import
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
Contact your local office