How to convert txt into mat

18 visualizzazioni (ultimi 30 giorni)
Slawomir Machaj
Slawomir Machaj il 8 Giu 2022
Risposto: VINAYAK LUHA il 8 Giu 2022
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.

Risposte (1)

VINAYAK LUHA
VINAYAK LUHA il 8 Giu 2022
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")

Community Treasure Hunt

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

Start Hunting!

Translated by