【问题标题】:How can I make a matrix average calculator in Scilab?如何在 Scilab 中制作矩阵平均值计算器?
【发布时间】:2013-10-28 14:47:27
【问题描述】:
【问题讨论】:
标签:
matlab
math
matrix
average
scilab
【解决方案1】:
您描述的问题与您发布的论文不同。我按照您的描述进行了操作,但将其拆分为多行,以便您轻松适应您的要求。
它与the MatLab answer 某人在您的其他问题中发布的非常相似。我不知道其他答案中使用的与 SciLab 中的 mat2cell 和 cellfun 类似的任何内容。
clear; clc
K = 100
N = 5
mid = floor(N/2)
volume = rand(K, K, K)
cubeCount = floor( K / N )
for x=0:cubeCount-1
for y=0:cubeCount-1
for z=0:cubeCount-1
// Get a cube of NxNxN size
cube = volume((1:N)+N*x, (1:N)+N*y, (1:N)+N*z);
//Calculate the average value of the voxels in the cube
avg = sum( cube ) / (N * N * N);
// Assign it to the center voxel
volume( N*x+mid+1, N*y+mid+1, N*z+mid+1 ) = avg
end
end
end
disp( volume )