How to convert txt into mat

3 ビュー (過去 30 日間)
Slawomir Machaj
Slawomir Machaj 2022 年 6 月 8 日
回答済み: VINAYAK LUHA 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 Center および File ExchangeWorkspace 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