Code to import file
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
How do i import a file that contains matrix to draw a graph please ? I want to do it with a code?
4 Commenti
Walter Roberson
il 5 Apr 2021
filename = 'test.txt';
%part 1: create some demonstration data to work with
s = randi(9, 15, 1);
t = randi(9, 15, 1);
writematrix([s,t], filename);
%part 2: read the demonstration data:
st = readmatrix(filename);
s = st(:,1);
t = st(:,2);
%part 3: create the graph:
G = graph(s, t);
%part 4: draw the graph:
plot(G)
It look s to me as if readmatrix() does in fact work.
Risposte (1)
Walter Roberson
il 5 Apr 2021
filename = 'test.txt';
%part 1: create some demonstration data to work with
s = randi(9, 15, 1);
t = randi(9, 15, 1);
writematrix([s,t], filename);
%part 2: read the demonstration data:
st = readmatrix(filename);
s = st(:,1);
t = st(:,2);
%part 3: create the graph:
G = graph(s, t);
%part 4: draw the graph:
plot(G)
It looks to me as if readmatrix() does in fact work.
0 Commenti
Vedere anche
Categorie
Scopri di più su Text Files 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!

