how to add ; in real time matrix in matlab?
Ältere Kommentare anzeigen
hi
i have a matrix of 1000 by 3. which i have to copy from some where and paste in the matlab. But as the matrix is classified as 100 by 3, so i have to add ; after every 3rd element. which is very much time consuming for considering that size of array. is there any method in matlab which print ; after every 3rd element. in the end i copy all array and past in my code. kindly help me :)
with best regards mudasir ahmed
Akzeptierte Antwort
Weitere Antworten (1)
Assuming you meant that the original matrix is 100x30 (not 100x3 which makes no sense), you could simply paste it as is and reshape afterwards:
m = reshape(m', 3, 1000)'
5 Kommentare
Mudasir Ahmed
am 31 Dez. 2015
Walter Roberson
am 31 Dez. 2015
Store the values in a text file. cellfun(@sym) the text.
fid = fopen('YourFile.txt', 'rt');
datacell = textscan(fid, '%s%s%s', 'CollectOutput', 1);
fclose(fid);
M = cellfun(@sym, horzcat(datacell{:}));
Mudasir Ahmed
am 1 Jan. 2016
Walter Roberson
am 1 Jan. 2016
fid = fopen('C:\Users\Mudasir Ahmed\Desktop\farhan.txt', 'rt')
datacell = textscan(fid, '%s %s %s', 'CollectOutput', 1, 'Delimiter', ',');
fclose(fid);
data = datacell{1};
M = sym(zeros(size(data));
for K = 1 : numel(data);M(K) = sym(data{K}); end
Mudasir Ahmed
am 1 Jan. 2016
Kategorien
Mehr zu Common Operations finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!