Matlab Array Division

조회 수: 3 (최근 30일)
tom rawr
tom rawr 2012년 2월 29일
Hello If I may please ask for help.
If I had an array say d1 that is 10x1. So numbers going downwards vertically.
I want to create a new array d2 that is the same as d1 but each value is in a calculation like "200/array value[1]"(up to all 10 in the array).
I cant get it to work and tried things like "d2=200/d1" but that just gives me a big row of 0's.
I need the output to be a same 10x1 column vector. Please see my pic for clarification: <http://desmond.imageshack.us/Himg713/scaled.php?server=713&filename=helpet.jpg&res=medium>
Thank you.

채택된 답변

Andrew Newell
Andrew Newell 2012년 2월 29일
It's just
d2 = 200./d1;
Note the dot. This is element-by-element division (see Matrix and array arithmetic).
  댓글 수: 1
tom rawr
tom rawr 2012년 2월 29일
Ah forgot the dot!! Thank you!!!

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

추가 답변 (1개)

James
James 2012년 2월 29일
try this
a=[1;2;3;4;5;6;7;8;9;10] anew1= [1/(a(1,:).^a);1/(a(2,:).^a) ;1/(a(3,:).^a); continue the pattern for the rest or the code up to 10.] so next one in the bracket is 1/(a(4,:).^a)
afinal= [ anew1(1,1);anew1(2:10,10)]

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by