multiplying a value and create a matrix of a certain size

조회 수: 1 (최근 30일)
Elaheh
Elaheh 2018년 6월 30일
댓글: Elaheh 2018년 6월 30일
The outcome of this line
B=strcat(num2str(i),',',str3);
is B =4,1,1. I would like to multiply B and create a matrix (a column vector) with the same size as data1 (which is a 748*3 matrix) so that I could create a new matrix like newMatrix=[data1 B] later on . Thank you.
  댓글 수: 7
Elaheh
Elaheh 2018년 6월 30일
편집: Image Analyst 2018년 6월 30일
I have one numeric matrix (748*3 double) and I have the following variable:
B=strcat(num2str(i),str3);
when I type B in the command window, I come up with:
B =
41,1
and it is 1*4 char.
B is the name of the matrix (i.e., data1, 748*3) and I want to have the name with the data in the excel file, because I have about 30 persons and each person has 4 pieces of data. Writing B this way enables me to create a name for each piece of data.
How could I do that?
Image Analyst
Image Analyst 2018년 6월 30일
B is the name of a character vector and is '41,1' -- it is not a matrix, and does not have value of 'data1, 848*3'. I think your terminology is confusing everybody.
I don't know what "each piece of data" is but why do you need a new, unique name for each piece?
Please answer my questions in Walter's answer also.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2018년 6월 30일
repmat(B, size(data1, 1), 1)
However if data1 is numeric then [data1 replicated_B] is unlikely to give you what you expect.
  댓글 수: 4
Elaheh
Elaheh 2018년 6월 30일
Considering the previous information, I would like to have something like the attached file.
Elaheh
Elaheh 2018년 6월 30일
i is the number of each participant. It will be changed for each person. str3 shows the test version and is the name of the excel sheet the data is taken from. They are string. data1 includes 3 columns which show the reaction time, type of the stimuli etc. I need to label each piece of data (i.e., data1) for each participant and for each test version. In other words, I need B to appear with the data. It would be ideal for B, which shows the number of each participant and the test version to appear on the top of data1. I can write the information in an excel file now but do not know how to add the file ID to the data (to data1). I attached a picture to show my intended output. The picture shows the file for each person. 40 is the number of participant and 1 is the test version.
Thank you and sorry for making you confused.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by