Error using reshape because "size arguments must be real integers"

12 views (last 30 days)
Activity_dff is a 1200640x1 matrix of decimal numbers. When trying to do this:
%% Calculate dff
fd = prctile(Activity_smooth,10); %baseline, f0
Activity_dff = Activity_smooth-fd ./ fd;
Activity_dff_ds = group_z_project_vector(Activity_dff,2560); %to see in epoch
I get this:
Error using reshape
Size arguments must be real integers.
Error in group_z_project_vector (line 6)
vector2 = reshape(vector,sz(1),group_z_value,slice_number);
Error in StimulusTestNew (line 95)
Activity_dff_ds = group_z_project_vector(Activity_dff,2560); %to see in epoch
And this is group_z_project_vector:
function [vector_zproj,std_zproj,SE_zproj] = group_z_project_vector(vector,group_z_value);
sz = size(vector);
% groupZ_value = sz(3)/slice_number;
slice_number = sz(2)/group_z_value; %giving 766
vector2 = reshape(vector,sz(1),group_z_value,slice_number); %% This is where I receive en error
vector_zproj = mean(vector2,2); %group_zvalue mean, meaning mean of the rows
std_zproj = std(vector2,[],3);
SE_zproj = (std(vector2,[],3))./slice_number;
vector_zproj = squeeze(vector_zproj); % Group Z project by appropriate number
std_zproj = squeeze(std_zproj);
SE_zproj = squeeze(SE_zproj);
Can you help wit this?
  1 Comment
Walter Roberson
Walter Roberson on 2 May 2020
Please check
mod(group_z_value,1)
mod(slice_number, 1)
You need both of those to be 0
Experiment with
vector2 = reshape(vector,sz(1),group_z_value,[]);

Sign in to comment.

Accepted Answer

Steven Lord
Steven Lord on 2 May 2020
You said that "Activity_dff is a 1200640x1 matrix of decimal numbers. " You then compute
sz = size(vector);
% groupZ_value = sz(3)/slice_number;
slice_number = sz(2)/group_z_value; %giving 766
sz(2) is 1 and group_z_value is 2560 meaning slice_number is much smaller than 1. It certainly isn't an integer value.
If your Activity_dff vector were a row vector (1x1200640) instead of a column vector then slice_number would be an integer value (though your comment is incorrect, it's not 766.)

More Answers (0)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!