How to name each row of a 4 by 4 matrix, that is calculated. Then plot those rows each in a separate figure?

조회 수: 1 (최근 30일)
Hello everyone,
I have two parts to my question:
  1. I wanted to ask if as part of my calculations, I get an output of a 4 by 4 matrix, however I want to name each row in this matrix, how? I saw other answers on the community mentioning using tables from the beginning but I beleive I cant do that as the matrix is calculated.
  2. Also how can I plot each row in this matrix in a separate figure?
Thanks in advance!
  댓글 수: 2
James Tursa
James Tursa 2019년 7월 17일
Please post some code or pseudo-code (or combination thereof) showing what you are trying to do, and then we can give you some suggestions.
dpb
dpb 2019년 7월 18일
Well, there's nothing to prevent casting the output matrix into table to use the RowNames property if that's what you want.
Whether it makes sense to use a table from the beginning depends largely on whether the data from which you start is suitable to a table or not. We have no way to judge w/ no info on the subject.
To plot, just create a loop and pass each row to plot(). Remember if do want a brand new figure to include the figure command in the loop to create a new one each pass...

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

채택된 답변

KSSV
KSSV 2019년 7월 18일
A = rand(4,4) ;
var = {'row1', 'row2','row3','row4'} ;
% Table
T = table(A, 'RowNames',var) ;
% Plot
for i = 1:4
figure(i)
plot(A(i,:))
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by