Info
This question is closed. Reopen it to edit or answer.
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
How I can read notbad file Line by Line?
2 views (last 30 days)
Show older comments
I saved matrices in text file line by line and now I want to read these matrices in same way that I saved?
2 Comments
Geoff Hayes
on 28 Mar 2015
Ameligege - what is the code that you used to save the data to file?
Answers (1)
Image Analyst
on 28 Mar 2015
Try dlmread(), csvread(), importdata(), fgetl(), textscan(), or readtable(). Lots of ways to do it. Examples are in the help. Just pick one or two and give it a try. In the event someone did want to do it for you, you didn't attach your file, so they can't.
19 Comments
Image Analyst
on 28 Mar 2015
So you used dlmwrite() to write it out
dlmwrite('Features.txt',reshapemat,'-append', 'newline', 'pc');
but dlmread() is not working? What is your code for dlmread()?
Ameligege
on 28 Mar 2015
Edited: Ameligege
on 28 Mar 2015
I used dlmread() as follwing
dlmread('Features.txt') but the result is not identical to the text file for example In the notebad file here is one of the values 407.66 but the output is 0.4077 what is the reason?
Image Analyst
on 28 Mar 2015
Well, what can I say if you're not willing to attach your file? Just keep working on it, or call the Mathworks on Monday for help. It looks like somewhere you're dividing the array by 100. Are you sure it's not just being displayed in scientific notation?
Image Analyst
on 28 Mar 2015
Why does it need to be private? It's just numbers. If there are secret words in some column headers, just change them, and then upload it here.
Image Analyst
on 28 Mar 2015
OK, so the first number in the file is 377. Was that the value in MATLAB before you created the file? And what number do you get after calling dlmread()? 377 or 0.377?
Image Analyst
on 28 Mar 2015
I can't reproduce:
m = dlmread('features.txt');
m(1, 2) % Print second number on first row to command line.
In the command window, it shows:
ans =
377.46
It works just fine for me. There's something you're not showing or telling me, like you're using im2double() or dividing by 100 or something.
Ameligege
on 29 Mar 2015
Edited: Ameligege
on 29 Mar 2015
Here are all my steps
1-Read Images
2-Apply Filter function after convert the image using im2double()
3-convert it to black and white
4-Apply DWT
5-Apply kraskuallwallis
6-reshape the result to save it in notbad file row by row
7-write the reult to notbad file
That all what I did before I saved the result in notbad file I can send the code but in private.
Image Analyst
on 29 Mar 2015
Right before step 7 (dlmwrite), do this:
save('myarray.mat', 'reshapemat');
dlmwrite('Features.txt',reshapemat,'-append', 'newline', 'pc');
Then attach myarray.mat back here so we can look at it.
Image Analyst
on 29 Mar 2015
This has totally different numbers than your first example (311 is not the first number anymore) so that means you're also going to have to attach the features.txt file that has the same numbers. Please hurry as I'm planning on leaving for some errands soon.
Image Analyst
on 29 Mar 2015
Edited: Image Analyst
on 29 Mar 2015
Here is the code I used:
s=load('myarray.mat')
m = s.reshapemat;
Then examine m with the variable editor. And you attached the same features.txt as before. It totally does not match your reshapemat in the slightest.
Ameligege
on 29 Mar 2015
Look :( I had to use this function reshapemat=reshape(features, 1, []);
to save the result matrix in one line.
because I want to save each matrix in one line like the notbad that I sent
If you have another way to do the same thing ,please tell me?
Thank you for the sincere help ,I appreciate you for your time and your effort
See Also
Tags
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
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)