nested structure from a vector

5 visualizaciones (últimos 30 días)
y0unes
y0unes el 1 de Ag. de 2017
Comentada: Jan el 1 de Ag. de 2017
I have this program for a Magnet Simulation :
Bxs = permute(reshape (Zylinder_B_x{:}(:,4), sizes),[2 3 1]);
Bys = permute(reshape (Zylinder_B_y{:}(:,4), sizes),[2 3 1]);
Bzs = permute(reshape (Zylinder_B_z{:}(:,4), sizes),[2 3 1]);
but Matlab returns the following error: Expected one output from a curly brace or dot indexing expression, but there were 4 results.
I like to understand what I am doing wrong.
Thanks in advance for your help

Respuestas (1)

Guillaume
Guillaume el 1 de Ag. de 2017
I like to understand what I am doing wrong It's easy to tell you what is wrong, harder to tell you how to fix it as we don't know the goal
The cause of the error is
Zylinder_B_x{:}
Since you get an error, Zylinder_B_x is a cell array with more than one element. The above returns a comma separated list of the contents of the cell array. You cannot index a comma separated list (with your (:, 4)).
You could possibly convert this comma separated list into a matrix (with [] or vertcat or something else) but we don't have enough information to make a guess (what's in the cell array?)
As said, it's unclear what's your goal. In particular, even if there were no errors, all 3 lines would produce exactly the same result.
  1 comentario
Jan
Jan el 1 de Ag. de 2017
@Guillaume: "all 3 lines would produce exactly the same result", see the different variables "Zylinder_B_ x, Zylinder_B_ y, Zylinder_B_ z".

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by