Matlab and SimuLink Development Forum
Matlab Tutorials
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Welcome to Matlab Forums
Home
Help
Search
Media
Login
Register
Matlab and SimuLink Development Forum
»
General Category
»
C and C++
»
Topic:
i/o
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: i/o (Read 3346 times)
dazjaz
Newbie
Posts: 1
Matlab Forum
i/o
«
on:
September 26, 2010, 10:28:21 AM »
need help loading data from chirp example 1 saved to file using save( 'data.txt', '-ascii) to array in c using fread().
t=0:0.001:2;
y=chirp(t,0,1,150);
spectrogram(y,256,250,256,1E3);
save('data.txt','-ascii');
thanks
Logged
50dolars
Newbie
Posts: 7
Matlab Forum
Re: i/o
«
Reply #1 on:
September 29, 2010, 07:00:09 AM »
what do you need to help mode ?
Logged
Clint
Newbie
Posts: 3
Matlab Forum
Re: i/o
«
Reply #2 on:
December 03, 2011, 11:51:16 AM »
Whenever something fails while reading a file the error flag is set to true, after that all subsequent read will fail. so when you find some error while reading and come over it reset the error flag to false before you proceed.
[size=0pt]
1
[/size][size=0pt]
[/color]
[/size][size=0pt]
[/color]
2
[/size][size=0pt]
[/color]
[/size][size=0pt]
[/color]
3
[/size][size=0pt]
[/color]
[/size][size=0pt]
[/color]
4
[/size][size=0pt]
[/color]
[/size][size=0pt]
[/color]
5
[/size][size=0pt]
[/color]
[/size][size=0pt]
[/color]
6
[/size][size=0pt]
[/color]
[/size][size=0pt]
[/color]
7
[/size][size=0pt]
[/color]
[/size][size=0pt]
[/color]
8
[/size][size=0pt]
[/color]
[/size][size=0pt]
[/color]
9
[/size][size=0pt]
[/color]
[/size][size=0pt]
[/color]
10
[/size][size=0pt]
[/color]
[/size][size=0pt]
[/color]
11
[/size][size=0pt]
[/color]
[/size][size=0pt]
[/color]
12
[/size][size=0pt]
[/color]
[/size][size=0pt]
[/color]
13
[/size][size=0pt]
[/color]
[/size][size=0pt]
[/color]
14
[/size][size=0pt]
[/color]
[/size][size=0pt]
[/color]
15
[/size][size=0pt]
[/color]
[/size][size=0pt]
[/color]
16
[/size][size=0pt]
[/color]
[/size][size=0pt]
[/color]
17
[/size][size=0pt]
[/color]
[/size][size=0pt]
[/color]
18
[/size][size=0pt]
[/color]
[/size][size=0pt]
[/color]
19
[/size][size=0pt]
[/color]
[/size][size=0pt]
[/color]
20
[/size][size=0pt]
[/color]
[/size][size=0pt]
[/color]
21
[/size][size=0pt]
[/color]
[/size][size=0pt]
[/color]
22
[/size][size=0pt]
[/color]
[/size][size=0pt]
[/color]
23
[/size]
[/color]
[/size]
[/t][/t] [size=0pt]
[/color]
// clearing errors
[/size]
[size=0pt]
[/color]
#include <iostream>
[/size]
[size=0pt]
[/color]
#include <fstream>
[/size]
[size=0pt]
[/color]
using
[/size]
[size=0pt]
[/color]
namespace
[/size]
std;
[size=0pt]
[/color]
int
[/size]
main () {
[size=0pt]
[/color]
char
[/size]
buffer [80];
fstream myfile;
myfile.open (
[size=0pt]
[/color]
"test.txt"
[/size]
,fstream::in);
myfile <<
[size=0pt]
[/color]
"test"
[/size]
;
[size=0pt]
[/color]
if
[/size]
(myfile.fail())
{
cout <<
[size=0pt]
[/color]
"Error writing to test.txt\n"
[/size]
;
myfile.clear();
}
myfile.getline (buffer,80);
cout << buffer <<
[size=0pt]
[/color]
" successfully read from file.\n"
[/size]
;
[size=0pt]
[/color]
return
[/size]
0;
}
Logged
Matlab and SimuLink Development Forum
Re: i/o
«
Reply #2 on:
December 03, 2011, 11:51:16 AM »
Print
Pages: [
1
]
Go Up
« previous
next »
Matlab and SimuLink Development Forum
»
General Category
»
C and C++
»
Topic:
i/o