How to convert txt into mat

4 次查看(过去 30 天)
Slawomir Machaj
Slawomir Machaj 2022-6-8
I've got a problem with conversion txt into mat.
I have tried using this code:
M = csvread('C:\Users\gieni\Desktop\Dane01.txt');
save('C:\Users\gieni\Desktop\Dane01.mat',"M")
but it gives out just one collumn instead of 3 as in txt file.
One of the problems, as i expect is collums are divided only by tab(i mean ' ').
I have no clue how to make it right. Another thing, I'd like to multiply every data from first and 2nd collumn by 1.43, but i couldn't even make it work with 3 collumns, so i haven't started with it yet.

回答(1 个)

VINAYAK LUHA
VINAYAK LUHA 2022-6-8
HI,
As per Mathworks this documentation csvread is not recommended and readmatrix should be used instead.
M=readmatrix('filepath')
M(:,1:2)=M(:,1:2).*1.43
save('filepath',"M")

类别

Help CenterFile Exchange 中查找有关 Workspace Variables and MAT Files 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by