text = fread(file, '*char')';
19 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% "Reading Text Data File" %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tic
fprintf('Reading data: ');
file = fopen('Data/source_data.txt');
text = fread(file, '*char')';
fclose(file);
toc
%%%there are an error in this part i need for help ing
2 Commenti
Jan
il 29 Ott 2022
If you assume, that there is an error and want others to solve it, it is useful to mention, what you observe. I cannot guess, what you call "error" here. Do you get an error message? If so, post a copy of the complete message.
Add the new information by editing the question, not by appending a comment.
SWARNENDU MONDAL
il 9 Nov 2022
Modificato: SWARNENDU MONDAL
il 9 Nov 2022
I faced the same problem, but here is one solution. This line
file = fopen('Data/source_data.txt');
will open the file 'source_data.txt', which is present in a inner folder named 'Data'.
If you are simulating online, then you have to upload that file also, and also you have to change the corresponding location.
I have upoladed it with the codes and didn't made anyinnder folder, so I have changed the code to this:
file = fopen('source_data.txt');
Remember you have to chenge another line.
f = fopen('Data/received.txt','w+');
to
f = fopen('received.txt','w+');
Risposte (1)
Bhanu Prakash
il 16 Feb 2023
Modificato: Bhanu Prakash
il 23 Feb 2023
Hi Doaa,
As per my understanding, you are trying to perform read operation on a text file.
Based on my assumption, the error might be present in the “fopen” command. For it to work, the text file “source_data.txt” must be present in the MATLAB path or the complete location of the file needs to be passed as an argument to the “fopen” command.
You can access the related documentation of “fopen” command and “adding folders to MATLAB path” here
Hope this answer helps you.
Thanks,
Bhanu Prakash.
0 Commenti
Vedere anche
Categorie
Scopri di più su Data Import and Analysis in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!