How I Can Read Matrices From text file and display it at separate Matrices?

2 次查看(过去 30 天)
I need to read matrices from notepad then display it in two separate matrices .I need also to calculate inverse then write the result back to notepad,please answer as soon as possible I searched for the answer in you tube to understand but I did not find.
THANKS

采纳的回答

Image Analyst
Image Analyst 2015-1-18
To read, try csvread(), dlmread(), importdata(), readtable(), textscan(), or a few other ways.
For display, you can use a uitable to display the matrix in a GUI. It's like a grid or spreadsheet control. Here's a demo:
clc;
% Create sample data and row and column headers.
columnHeaders = {'n', 'Data Set #1', 'Data Set #2'};
for n=1:10,
rowHeaders{n} = sprintf('Row #%d', n);
tableData{n,1} = n;
tableData{n,2} = 10*rand(1,1);
tableData{n,3} = sprintf(' Value = %.2f %s %.2f', rand(1,1), 177, rand(1));
end
% Create the table and display it.
hTable = uitable();
% Apply the row and column headers.
set(hTable, 'RowName', rowHeaders);
set(hTable, 'ColumnName', columnHeaders);
% Display the table of values.
set(hTable, 'data', tableData);
% Size the table.
set(hTable, 'units', 'normalized');
set(hTable, 'Position', [.1 .1 .8 .8]);
set(hTable, 'ColumnWidth', {40, 120, 180});
set(gcf,'name','Image Analysis Demo','numbertitle','off')
To write out to a text file, use fullfile(), fopen(), fprintf(), and fclose() - see documentation for examples.
It's nice to see that you looked for a solution on your own (YouTube) before asking here. That's one of the points listed in our tutorial: http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer Of course I'd probably search Answers first, then the newsgroup, then YouTube or the internet in general.

更多回答(1 个)

dpb
dpb 2015-1-18
Presuming you really mean a text file and not Notepad formatted,
doc textscan
doc importdata
and friends.
help iofun % and see which seem to fit your data bestest...

Community Treasure Hunt

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

Start Hunting!

Translated by