nested structure from a vector

5 Ansichten (letzte 30 Tage)
y0unes
y0unes am 1 Aug. 2017
Kommentiert: Jan am 1 Aug. 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

Antworten (1)

Guillaume
Guillaume am 1 Aug. 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 Kommentar
Jan
Jan am 1 Aug. 2017
@Guillaume: "all 3 lines would produce exactly the same result", see the different variables "Zylinder_B_ x, Zylinder_B_ y, Zylinder_B_ z".

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by