i want a good syntax form

s is matrix that has 6 rows and Qbar is an array that contains n number of matrices matrices
s(1,:)*Qbar{1}
s(2,:)*Qbar{1}
s(3,:)*Qbar{2}
s(4,:)*Qbar{2}
s(5,:)*Qbar{3}
s(6,:)*Qbar{3}
this is how i want it to be
is there any syntax i can make this happen?

Respuestas (2)

KALYAN ACHARJYA
KALYAN ACHARJYA el 16 de Mayo de 2022

0 votos

Using loop: Is that OK?
data_cell=cell(..,..) %Preallocate Memory
iter=1:3:size(s,1);
for i=1:3:6
data_cell{i}=s(i,:)*Qbar{i}
data_cell{i+1}=s(i+1,:)*Qbar{i}
end

6 comentarios

Mahmoud Chawki
Mahmoud Chawki el 16 de Mayo de 2022
it is saying Invalid use of operator.
on the rist line of the code
Mahmoud Chawki
Mahmoud Chawki el 16 de Mayo de 2022
first*
Mahmoud Chawki
Mahmoud Chawki el 16 de Mayo de 2022
also Q bar consists of 3 elements and i is exceeding that since matrix s consists of 6 rows
KALYAN ACHARJYA
KALYAN ACHARJYA el 16 de Mayo de 2022
"also Q bar consists of 3 elements and i is exceeding that since matrix s consists of 6 row;"
I dont think so, the loop runs for 3 times one for the particular case, not 6.
Mahmoud Chawki
Mahmoud Chawki el 16 de Mayo de 2022
i have an array of matrices which is:
Qbar{i}=inv(Sbar{i})
do you know how can i exctract each matrix from this array of matrices?
KALYAN ACHARJYA
KALYAN ACHARJYA el 16 de Mayo de 2022
array of matrices can be store as Cell array, it can be extarted using { } bracket
mat{1} represents the first matrics with the cell array.

Iniciar sesión para comentar.

Mahmoud Chawki
Mahmoud Chawki el 16 de Mayo de 2022

0 votos

yes i know but how can i store what im extracting without having to assign them each time manually

Categorías

Más información sobre Operators and Elementary Operations en Centro de ayuda y File Exchange.

Preguntada:

el 16 de Mayo de 2022

Respondida:

el 16 de Mayo de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by