How to solve it for a scalar output?
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I'm trying to find the electron current using the relation J=sigma[E+uxB]
for which my code gives an error
Unable to perform assignment because the left and right sides have a different number of elements.
Error in pde2fshear_fisher_new>pdex2pde (line 738)
je(STEP_x)=sig*(DuDx(1)+cross(ue,Bt));
which I'm unable to debug it
my code is as below
function [c,f,s] = pdex2pde(x,t,u,DuDx)
c = [1;1;1];STEP_x=2; zone=1;B0=4617;a=.9;R0=6; ue = [1.0;0;0];
xmin = 0;xmax = 1;xstep = 100; sig=1;
X = linspace(xmin,xmax,xstep-1);
if STEP_x==1
Btx=B0/(R0/a+zone*X(STEP_x));
Bt=[Btx;0;0];
je(STEP_x)= sig*(DuDx(1)+cross(ue,Bt));
elseif STEP_x > 1 && STEP_x <= 5
Btx=B0/(R0/a+zone*X(STEP_x));
disp(Btx);
Bt=[Btx;0;0];
je(STEP_x)=sig*(DuDx(1)+cross(ue,Bt));
else
Btx=B0/(R0/a+zone*X(STEP_x));
Bt=[Btx;0;0];
je(STEP_x)=sig*(DuDx(1)+cross(ue,Bt));
end
end
0 个评论
回答(1 个)
Torsten
2024-9-6
移动:Torsten
2024-9-6
cross(...) usually gives a vector as result, but je(STEP_x) is a scalar. You can't assign a vector to a scalar.
a(1) = cross([1 2 3],[4 5 6])
3 个评论
Walter Roberson
2024-9-6
je(STEP_x) = sig*(DuDx(1) + norm(cross(ue,Bt)));
Question:
What is the difference between your three branches? The only difference I can see is that you have an extra disp(Btx); in one of the branches.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 PDE Solvers 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!