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

9 ビュー (過去 30 日間)
Samuele Bolotta
Samuele Bolotta 2020 年 5 月 2 日
回答済み: Steven Lord 2020 年 5 月 2 日
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 件のコメント
Walter Roberson
Walter Roberson 2020 年 5 月 2 日
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,[]);

サインインしてコメントする。

採用された回答

Steven Lord
Steven Lord 2020 年 5 月 2 日
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.)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by