MATLAB Answers

Translated by

이 페이지의 내용은 영어에서 자동 번역되었습니다. 자동 번역 기능을 해제하려면 "<a class="turn_off_mt" href="#">여기</a>"를 클릭하십시오.

How to find rearrange these values in a new row and column?

For example: I have the following array of data.
column 1 column 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
I would like to make a new array of data sets with
column 1 column 2
2 3
4 5
5 6
8 9
What would be the best command to rearrange the matrix?

  0 Comments

Sign in to comment.

2 Answers

Answer by Star Strider
on 15 Feb 2019
 Accepted Answer

One approach:
A = [1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9];
L = ismember(A(:,1), [2 4 5 8]);
B = A(L,:)
produces:
B =
2 3
4 5
5 6
8 9

  0 Comments

Sign in to comment.


Answer by madhan ravi
on 15 Feb 2019

newmatrix = matrix([2 4 5 8],:)

  4 Comments

Thank you soo much for your suggestion.
Unfortunately it doesn't work. Maybe its because the first data is not in terms of rows and columns.
Admittedly, I feel a bit stuck about this. Rather than continuing, I'm wondering if I could lean on your expertise and insights to learn how to do it.
Below is the current code that I'm working on:
numData=xlsread('Original.xlsx','original');
FrontFaceNodes=numData(:,1);
TotalNodes=numData(:,10);
Totalstress=numData(:,11);
Total_nodes_stress(:,1)=TotalNodes;
Total_nodes_stress(:,2)=Totalstress;
Max_stress=max(max(Total_nodes_stress(:,2)));
Ave_stress=mean(mean(Total_nodes_stress(:,2)));
Newmatrix=Total_nodes_stress([FrontFaceNodes(:,1)],:);
Could you attach your file? and please explain what you want to do.
I managed to solve the problem. Thank you soo much for your consideration. If you don't mind, I have another question that I would like to ask. Feel free to have a look at the link below:
Please accept my apologies for asking a lot of questions, i'm still new to MATLAB and eager to learn more about it.

Sign in to comment.



Translated by