Info
此问题已关闭。 请重新打开它进行编辑或回答。
How I can read notbad file Line by Line?
1 次查看(过去 30 天)
显示 更早的评论
I saved matrices in text file line by line and now I want to read these matrices in same way that I saved?
2 个评论
此问题已关闭。
回答(1 个)
Image Analyst
2015-3-28
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 个评论
Image Analyst
2015-3-28
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()?
Image Analyst
2015-3-28
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
2015-3-28
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
2015-3-28
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
2015-3-28
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
2015-3-29
编辑:Ameligege
2015-3-29
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
2015-3-29
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
2015-3-29
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
2015-3-29
编辑:Image Analyst
2015-3-29
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
2015-3-29
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
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)