Looping Through Matrix indexing

I'm trying to solve an equation with multiple values for two variables. I can't seem to get the inner matrix to work which is variable Pc...
clear all, clc;
Mc = [120.2 119.9 119.9 119.9 119.7 119.8 119.6 119.3 119.1]; Pc = [121.4 121.4 121.3 121.2 121.5 121.7 121.6 121.8 121.5];
Vc = Mc(:)*cosd(Pc(:)) + Mc(:)*sind(Pc(:))*i

 Respuesta aceptada

Ced
Ced el 22 de Oct. de 2014
Hi Since you want to compute Vc for each element, you need to use element-wise operations, meaning you have to add a dot "." in front of the operator as such:
Vc = Mc.*cosd(Pc) + Mc.*sind(Pc)*i
Cheers

Más respuestas (1)

C
C el 22 de Oct. de 2014

0 votos

Wow... it's like magic lol, Thank you!

1 comentario

José-Luis
José-Luis el 22 de Oct. de 2014
Please accept an answer if it solved your problem.

Iniciar sesión para comentar.

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Preguntada:

C
C
el 22 de Oct. de 2014

Comentada:

el 22 de Oct. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by