简体   繁体   中英

Matlab:: extract data from created plot(existing)

I have a problem using matlab to extract data from a created plot. My doubt is if I have a multi-line plot and if I want the values of y(1), y(2), y(3).............(as it is a multi-line plot we will have ny's for every given x ) for every 0.1 increase in x what should I do ???

I don't need it in excel If I am able to call it I can use it in a condition like this "y(1)*k1 + y(2)*k2 + y(3)*k3 +........." here K1, K2, K3...... re constants which will be given by the user........

I tried this

for x = x1:0.1:x2    
    h = findobj(gca,'Type','line'); ;
    y = get(h,'Ydata');
     if (y{1}*xa +y{2}*xb+ y{3}*xc)==760;
         fprintf('T=  ,%0.2f/n',T); 
     end
end

If you have multiple plots your line:

h = findobj ( gca, 'Type', 'line' )

will return multiple line handles. Which you need to loop around

edit added the x loop.

You can keep your x loop as before (from my interpretation of your comment, x is not the same as XData?)

for x = x1:0.1:x2   
  for iH = 1:length(h)
    y = get ( h(iH), 'YData' )
    % your code goes here, e.g.

  end
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM