Filter löschen
Filter löschen

how to loop it

1 Ansicht (letzte 30 Tage)
Rizwana
Rizwana am 30 Jan. 2014
Kommentiert: Jos (10584) am 30 Jan. 2014
I have two columns. Both columns reads 264 elements and lets call them x & y.
x= 264*1 % reads radius r
y =264*1 % reads angle theta
I want to multiply first element of x with 1st element of y & 2nt elemnt of x with 2nd elemnt of y. How to do it... I used this logic. Its not working... Please help me
for i = 1 :264
x_new = x(i) * cosd(y(i))
y_new = y(i) * sind(y(i))
end

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 30 Jan. 2014
Bearbeitet: Azzi Abdelmalek am 30 Jan. 2014
Use the multiplication element by element .*
z=x.*y
x_new=x.*cosd(y)
y_new=y.*sind(y)
  1 Kommentar
Rizwana
Rizwana am 30 Jan. 2014
Thank You. Iam getting it now :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Iain
Iain am 30 Jan. 2014
Change:
x_new = x(i) * cosd(y(i))
y_new = y(i) * sind(y(i))
to
x(i+1) = x(i) * cosd(y(i))
y(i+1) = y(i) * sind(y(i))

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by