how to use the data from .dat file for plotting graph

조회 수: 87 (최근 30일)
Siddharth Pande
Siddharth Pande 2014년 6월 3일
댓글: Star Strider 2014년 11월 17일
I generated a data file in .dat form using a spice tool now I want to call this data file in matlab and use the x and y coordinates from the data file to plot the data in matlab .I am attaching the file having my data it is in txt format now as the attachments doesn't accept .dat format so anyone working with my file plz change the extension to .dat.

답변 (2개)

Star Strider
Star Strider 2014년 6월 3일
I do not know if this would work for ‘.dat’ files, but it works for the ‘.txt’ file you posted:
T = readtable('switch.txt', 'HeaderLines', 5, 'Delimiter','\t','ReadVariableNames',false);
Time = T.Var2;
iv1 = T.Var3;
figure(1)
plot(Time, iv1)
grid
  댓글 수: 7
Siddharth Pande
Siddharth Pande 2014년 6월 4일
thanks a lot for your help i had to make a little modification ,it worked thanks again
Star Strider
Star Strider 2014년 6월 4일
편집: Star Strider 2014년 6월 4일
My pleasure!
(The sincerest form of appreciation here on MATLAB Answers is to Accept the Answer that most closely solves your problem.)

댓글을 달려면 로그인하십시오.


Daniel
Daniel 2014년 10월 17일
Hi guys, I have a similar problem. I saved some data in a .dat file. I can load the data to matlab and it saves it in an array but I don't know how to plot a graph using the data. Any help would be appreciated.
  댓글 수: 2
Siddharth Pande
Siddharth Pande 2014년 11월 17일
download my txt file now take star strider's code to the command line of matlab and see how it works try to use matlab 2013. as text scan function is provided in latest version
if you get any idea from it then you could simply chang yours
be sure when working with your file change the .dat file to .txt and run the code search for cell2mat function and textscan function in matlab help
Star Strider
Star Strider 2014년 11월 17일
@Siddharth Pande —
I very much appreciate your recommending my Answer. Now would your please Accept it?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by