필터 지우기
필터 지우기

solving simple equations in matlab

조회 수: 3 (최근 30일)
Richard
Richard 2012년 12월 18일
I have 2 variables:
d1 = 1:5;
d2 = 6:10;
I would like to calculate 'dat', which is given by:
dat = d1./(10.*d2);
However, the following returns a vector (as expected), how would I write this so that matlab returns a matrix i.e. the value for dat when d1 is 1:5 when d2 is 6 and then when d2 is 7, ultimately returning a 5x5 matrix. Is the only method of completing this through a loop.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 12월 19일
편집: Andrei Bobrov 2012년 12월 19일
dat = d1.'*(.1./d2);

추가 답변 (2개)

Walter Roberson
Walter Roberson 2012년 12월 18일
dat = bsxfun(@rdivide, d1.', d2) ./ 10;

Babak
Babak 2012년 12월 18일
편집: Babak 2012년 12월 18일
d1 = 1:5;
d2 = 6:10;
for j=1:5
dat(j,:) = d1./(10.*d2(j));
end
dat

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by