Element wise cell division

21 vues (au cours des 30 derniers jours)
MarshallSc
MarshallSc le 24 Juil 2021
Réponse apportée : Jan le 24 Juil 2021
This might sound very basic and silly, but I have two cells with complex doubles that I need to divide element wise. The problem is that I get the same value for each division for every cell that is not correct. And the results that I get are not in complex double (0.1429) while they should be. I have attached my data and the code is very basic:
A=cell(4,4);
for i=1:4
for j=1:4
A{i,j}=S{i,j}./(S{i,j}-V{i,j});
end
end
The results of the element wise division should be in compelx nature but they are not. Am I doing something wrong here? Sorry if the question is very basic.
  2 commentaires
Max Heiken
Max Heiken le 24 Juil 2021
It seems to me that 0.1429 is in fact the correct solution everywhere given your data and equation... Are S and V perhaps the result of some decomposition or something?
MarshallSc
MarshallSc le 24 Juil 2021
Yes, they are actually individual decompositions of a same cell. It appears that 0.1429 is in fact the answer, but it doesn't make sense because the ratios have to render different values. I guess, for this operation, there is not other answer. Thank you for your reply.

Connectez-vous pour commenter.

Réponse acceptée

the cyclist
the cyclist le 24 Juil 2021
Your code is producing the correct result. You could also have used the cellfun() function to do this operation in one line:
A = cellfun(@(x,y)(x./(x-y)),S,V,'UniformOutput',false)

Plus de réponses (1)

Jan
Jan le 24 Juil 2021
S{i,j} ./ (S{i,j} - V{i,j}) =
1 ./ (1 - V{i,j} ./ S{i,j})
and for all V and S the division V ./ S replies the elements -6.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by