Add row in a matrice

조회 수: 3 (최근 30일)
MR JUSTIN ACHARJEE Sumanta
MR JUSTIN ACHARJEE Sumanta 2021년 12월 10일
댓글: MR JUSTIN ACHARJEE Sumanta 2021년 12월 10일
I want to add matrice W as a new row beneath matrice M, and make a new matrice, T. W and M is working, but for T there is no result showing. What did I do wrong?
%% Q7b
clear;clc;
F=[400 550 700 500 600];
D=[3 0.5 0.75 1.5 5];
W=F.*D
M = dlmread('Table.csv',',')
T=[M;W];
  댓글 수: 2
KSSV
KSSV 2021년 12월 10일
To achieve that the number of columns in M and W should be same. Are they in your case?
What error you are getting? What is dimension of M?
MR JUSTIN ACHARJEE Sumanta
MR JUSTIN ACHARJEE Sumanta 2021년 12월 10일
Matrice M is a 2x5 matrice. T is 1x5.

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

답변 (1개)

Rik
Rik 2021년 12월 10일
You did nothing wrong.
You only forgot that using the semicolon (the ; symbol) will suppress the output of a function. That is actually best practice.
You should normally always suppress the output of a function and use dedicated functions like disp and fprintf to show any output. That way you also don't have to get into the habit of starting every function/script with clc.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by