我有Matlab问题,请提前感谢您的帮助!
我有一个csv文件的代码,最后,我得到一个值,让它称之为DesiredValue。
我有一个包含许多csv文件的文件夹,命名为:Cells_1A1,Cells_2A1,Cells_3A1,Cells_1B1,Cells_2B1,Cells_3B1。
这里,开头的1 2 3指的是时间点。
我想扩展我的代码 1.代码为每个文件生成DesiredValue 2.它取所有名称以1开头的文件(Here- Cells_1A1,Cells_1B1)的平均值,并以2开始(Here- Cells_2A1,Cells_2B1)并计算标准偏差并绘制它。 3.如何在循环外部存储此矩阵,使其值不会被写入 - 因为我有多个这样的文件夹,最后我想比较同一图表上不同文件夹的图。
我的代码是:
%**************************************************************************
% Reading the csv files generated by CellProfiler
%**************************************************************************
%**************************************************************************
% Reading data for each cell
%**************************************************************************
A = csvread('Cells_2C1.csv',1,0);
XCell = A(:,3); % x coordinate of centroid
YCell = A(:,4) % y coordinate of centroid
%**************************************************************************
% Reading data for spheroid
%**************************************************************************
% JAREK : this will never be empty.
B = csvread('Spheroid_2C1.csv',1,0);
XSpheroid= B(:,4); % x coordinate of centroid
YSpheroid= B(:,5); % y coordinate of centroid
AreaSpheroid = B(:,3); % Area of spheroid
%**************************************************************************
% Radius of the uniform circle centered at the centroid of the spheroid
% with the same area as the spheroid
%**************************************************************************
UniformRadius = sqrt(AreaSpheroid*(7/22));
%**************************************************************************
% Distance between centroid of spheroid and the centroid of each cell
%**************************************************************************
XSpheroidResized = repmat(XSpheroid,size(XCell)); % make dimension of spheroid coordinates
YSpheroidResized = repmat(YSpheroid,size(YCell)); % matrices same as cells' coordinates matrices
X = XCell - XSpheroidResized; % X coordinates of the distance
XSquare = X.*X;
Y = YCell - YSpheroidResized; % y coordinate of the distance
YSquare = Y.*Y;
DistanceSquare = XSquare + YSquare;
DistanceBetweenCentroids = sqrt(DistanceSquare);
%**************************************************************************
% Distance between boundary of uniform circle and centroid each cell
%**************************************************************************
repmat(UniformRadius, size(XCell); % making dimension of uniform radius same as that of
% cells' coordinates matrices
DistanceUniformBoundaryAndCell = abs(DistanceBetweenCentroids - repmat(UniformRadius, size(XCell)))
%**************************************************************************
% Distance of the cell furthest away from the boundary of the regular
% circle
%**************************************************************************
DesiredDistance = max(DistanceUniformBoundaryAndCell);