Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

problems using slice function

Asked by Bran

Bran (view profile)

on 16 Jan 2013

I have been having some problems using the slice function; I am using the following code;

x = [-7:1:9]
y = [-7:1:9]
z = [-7:1:9]
zslice = [0, 5, 9]
v = my_ans (fft values calculated)
slice(x,y,z,v,zslice)

The error message I am getting is as follows;

Warning: Specifying the number of columns is no
longer necessary. Use slice(v,xi,yi,zi) instead. 
> In slice at 55 
Error using  / 
Matrix dimensions must agree.
Error in slice (line 57)
        v =
        reshape(v,size(v,1)/args{5},args{5},size(v,2)); 

Any ideas what the problem is??

Many thanks

:)

0 Comments

Bran

Bran (view profile)

Products

No products are associated with this question.

1 Answer

Answer by Walter Roberson

Walter Roberson (view profile)

on 17 Jan 2013
Edited by Walter Roberson

Walter Roberson (view profile)

on 17 Jan 2013

The only way that slice() takes 5 arguments is if the last argument is a string indicating the interpolation method.

There are four-argument versions of slice() in which V is the first argument, but those only have one z.

There are seven-argument versions of slice() in which x, y, z, and v are the first four arguments, but the last three arguments must be xi, yi, zi. You seem to have left out the xi and yi.

http://www.mathworks.com/help/matlab/ref/slice.html

0 Comments

Walter Roberson

Walter Roberson (view profile)

Contact us