Unable to perform assignment because the size of the left side is 1-by-3 and the size of the right side is 7-by-3.

2 Ansichten (letzte 30 Tage)
i am trying to simulate 3D medium with source and detector in matlab using TOAST. i am getting following error,
Unable to perform assignment because the size of the left side is 1-by-3 and the size of the right side is
7-by-3.
Error in demo3d (line 53)
Q(2,:) = r1 * [sin(t1)*cos(p1) sin(t1)*sin(p1) cos(t1)];
the code is follows,
clear all
close all
%% Geo parameters
r1 = 12;
nd = 1;
rfac = 0.25;
r2 = r1*rfac;
x = 0.4;
y = 0.4%5;
z = 0%-5;
x = r1*x;
y = r1*y;
z = r1*z;
%% Create the mesh/Load the mesh
mesh = toastMesh('sphere_test_toast.msh');
figure (1)
%mesh.Display
freq = 0; % modulation frequency [MHz] %0 for CW system
%% Create the background parameters
muaB = 0.01;
musB = 1.0;
refrec = 1.4;
nodes = mesh.Data;
figure (2)
scatter3(nodes(:,1),nodes(:,2),nodes(:,3),20,'filled');
nodesB = nodes(sqrt((nodes(:,1)-x).^2+(nodes(:,2)-y).^2+(nodes(:,3)-z).^2)>r2,:);
mua = ones(size(nodes,1),1).*muaB;
mus = ones(size(nodes,1),1).*musB;
ref = ones(size(nodes,1),1).*refrec;
figure (3)
scatter3(nodes(:,1),nodes(:,2),nodes(:,3),20,mua,'filled');
ax = gca;
view(-36.5,16)
cb = colorbar;
figure (4)
scatter3(nodes(:,1),nodes(:,2),nodes(:,3),20,mus,'filled');
ax = gca;
view(-36.5,16)
cb = colorbar;
%% Placing the S/D
t1 = 0; p1 = 0;
Q(1,:) = r1 * [sin(t1)*cos(p1) sin(t1)*sin(p1) cos(t1)];
t1 = pi; p1 = 0;
Q(2,:) = r1 * [sin(t1)*cos(p1) sin(t1)*sin(p1) cos(t1)];
t2 = 2*pi/4; p2 = 0;
D(1,:) = r1 * [sin(t2)*cos(p2) sin(t2)*sin(p2) cos(t2)];
t3 = t2; p3 = pi/2;
D(2,:) = r1 * [sin(t3)*cos(p3) sin(t3)*sin(p3) cos(t3)];
t4 = t2; p4 = pi;
D(3,:) = r1 * [sin(t4)*cos(p4) sin(t4)*sin(p4) cos(t4)];
t5 = t2; p5 = 3*pi/2;
D(4,:) = r1 * [sin(t5)*cos(p5) sin(t5)*sin(p5) cos(t5)];
%% Visualize the mesh with S-D
mesh.SetQM(Q,D);
ShowD = [1,3,4];
figure (5)
mesh.Display()
s1 = scatter3(nodesB(:,1),nodesB(:,2),nodesB(:,3),20,'filled','MarkerFaceColor','b');
alpha(s1,.2)
ax = gca;
view(-36.5,16)
cb = colorbar;
hold on
scatter3(Q(:,1),Q(:,2),Q(:,3),'ro','MarkerFaceColor','y');
scatter3(D(ShowD,1),D(ShowD,2),D(ShowD,3),'ro','MarkerFaceColor','r');
%% Solve the forward problem
qvec = mesh.Qvec('Neumann', 'Gaussian', 2);
mvec = mesh.Mvec('Gaussian', 2,0);
K = dotSysmat(mesh,mua,mus,ref,freq);
Phi = K\qvec;
Y = mvec.' * Phi;
logY = log(Y);
lnamp = real(logY);
phase = imag(logY);
figure (6)
hold on
angle = [90:360/4:360];
for i=1:size(lnamp,2)
ywrap = [lnamp(i:end,i); lnamp(1:i-1,i)];
plot(angle,ywrap,'o-');
end
axis([0 360 -14 -2]);
xlabel('angular source-detector separation');
ylabel('log intensity');
kindly help me.

Antworten (1)

Jan
Jan am 23 Nov. 2022
"Unable to perform assignment because the size of the left side is 1-by-3 and the size of the right side is 7-by-3."
This error message cannot be produced by this code:
r1 = 12;
...
t1 = pi; p1 = 0;
Q(2,:) = r1 * [sin(t1)*cos(p1) sin(t1)*sin(p1) cos(t1)];
This means, that you did not post the failing code but another one. Then the readers do not have a change to guessm what the problem is.
Use the debugger to find out, which code is actually failing:
dbstop if error
Type this in the command window, start the code and see, where Matlab stops. Now you can check the dimensions of the variables used in this line.

Kategorien

Mehr zu Graphics Performance finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by