Error using horzcat dimensions
6 次查看(过去 30 天)
显示 更早的评论
I'm having issues with my end output. It seems to be due to the id variable.
This is printed when ran;
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
Error in week5analysis (line 30)
output=[id dacc drt];
function [output]=week5analysis(data)
%input should create a directory of one or more files
files=dir(data);
%index k should correspond to the number of files within the directory
for k=1:size(files,1)
%extracting id and converting to corresponding number
id=(files(k).name(4:size(files(k).name,2)));
%loading the files within the directory
temp=load(files(k).name);
%removes the first 10 practice trails in both conditions
temp([1:10,51:60],:)=[];
%condition 1
c1=temp(temp(:,1)==1,:);
%condition 2
c2=temp(temp(:,1)==2,:);
%displays the percentage of correct answers for condition 1
acc1=sum(c1(:,2)==1)/numel(c1(:,2))*100;
%displays the percentage of correct answers for condition 2
acc2=sum(c2(:,2)==1)/numel(c2(:,2))*100;
%mean of reaction time for correct trails in condition 1
c1m=mean(c1(c1(:,2)==1,3));
%mean of reaction time for correct trails in condition 2
c2m=mean(c2(c2(:,2)==1,3));
%difference between each condition for accuracy
dacc=c1(:,2)-c2(:,2);
%difference between each condition for reaction time
drt=c1(:,3)-c2(:,3);
%saves difference scores alongside id
output=[id dacc drt];
end
0 个评论
采纳的回答
Star Strider
2019-11-8
I have no idea what your code does or what the variables are that you want to return.
The easiest approach is to return a cell array instead:
output = {id dacc drt};
Note the curly brackets {} denoting a cell array.
4 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!