multiplying or dividing vectors

I am missing something and I can't figure out what to do. I am trying to divide these 2 vectors. So I want the first number in vector one divided by the first in vector 2. The second in vector 1 divided by the second in vector 2. I get this error Error: Unbalanced or unexpected parenthesis or bracket. Where am I messing up with the syntax? I know its the "speedf." but I don't know how else to write it. Thank You.
speed=[10 20 30 40 50 60 70];
speedf=[speed.*5290/86400];
rd=[11 22 33 44 55 66 77];
rxt=[rd./speedf.]

 채택된 답변

Oleg Komarov
Oleg Komarov 2011년 9월 8일

1 개 추천

speed = 10:10:70;
speedf = speed * (5290/86400);
rd = 11:11:77;
rxt = rd./speedf;
The error was just the point after rd./speedf.
I suggest:
  • do not abuse the parentheses
  • try to understand when to use .* or *

댓글 수: 6

Sean Smith
Sean Smith 2011년 9월 8일
thank you for your help, just wondering what if the speed and rd weren't perfectly spaced out, if they were random numbers such as [2 7 23 45 65 66 70]. then how would you do it?
Oleg Komarov
Oleg Komarov 2011년 9월 8일
randi([1 70],[1 7])
Sean Smith
Sean Smith 2011년 9월 8일
I tried the code you said to use but its just returning 17.966 7 times. which is just 11/.6122685. the first cell divided by the first cell. its not going through all of them. any ideas?
Jan
Jan 2011년 9월 8일
speed*5290/86400 is slower than speed*(5290/86400).
Oleg Komarov
Oleg Komarov 2011년 9월 9일
@Sean: of course, what did you expect? Algebra.
Oleg Komarov
Oleg Komarov 2011년 9월 9일
rxt = (11:11:77)./((10:10:70) * (5290/86400)); --> (5290/86400)^-1 * 1.1

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by