How to split data of a .mat file into trainH trainY testH testY as shown in picture

8 Kommentare

please attach your data
I have only this cmc dataset containing these above matrices.
even we can't see the dimension.
trainH=1000 X 9
trainY= 1000 X ?? what ?
testH=473 X 9
testY=473 X 1
it looks cmc.mat is a mat file with 4 variables(trainH,trainY,testH,testY)
if you open cmc.mat file you can get these 4 variables. why do you want to split these variables again from cmc.mat?
load('cmc.mat')
I don't need to split it i just show how i want my dataset. i'm having another another dataset where i need to split.
You will need to post your dataset and more comments about what you want to do in order for the Community to offer a helpful answer.
uma
uma am 9 Mär. 2022
Bearbeitet: Stephen23 am 10 Mär. 2022
I have a .mat file dataset containg four variables trainH trainY...as you can see in the above picture. Now want these fours variables in another dataset in the same way...may be this is done in the CSV file.
I have attached both my .csv and .mat dataset I just want something like this
struct with fields:
trainH: [1000×9 double]
trainY: [1000×1 double]
testH: [473×9 double]
testY: [473×1 double]

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

My guess:
1st step: load your cmc.mat file in Variable A as a struct.
2nd step: extract your 4 variables from struct A.
A=load('cmc.mat');
trainH=A.trainH ;
trainY=A.trainY;
testH=A.testH;
testY=A.testY;

9 Kommentare

what would be in the field trainH tainY(A.trainY).... that is non existant field.
Arif Hoq
Arif Hoq am 10 Mär. 2022
Bearbeitet: Arif Hoq am 10 Mär. 2022
i cant get your question. in struct A there would be 4 fields(trainH,trainY,testH,testY). if you want to extract these fileds then try previous response
I have attached both my .csv and .mat dataset I just want something like this
struct with fields:
trainH: [1000×9 double]
trainY: [1000×1 double]
testH: [473×9 double]
testY: [473×1 double]
It does not make any sense. segment.mat file has 2310 rows and 25 columns. you can get your 4 variables (trainH,trainY,testH,testY) randomly. but you should make us clear which row and column want to extract from segment.mat .
First I want to extract all rows and colunms from the segment.mat and want to store in TrainH
its simple
A=readtable('segment.csv');
trainH=table2array(A); % converting into array from table
trainH is 2310 X 25 array. it means 2310 rows and 25 columns
In workspace we will get a variable trainH but now I want this variable inside in the mat file just like above cms mat file contains.
move your mouse cursor to the variable trainH.
Right Click > save as> write your fileName (cmc)>save
Thank you so much. It was just to do drag and drop

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Gefragt:

uma
am 9 Mär. 2022

Kommentiert:

uma
am 14 Mär. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by