How to solve it for a scalar output?
2 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Torsten
on 6 Sep 2024
Moved: Torsten
on 6 Sep 2024
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 Comments
Walter Roberson
on 6 Sep 2024
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.
See Also
Categories
Find more on PDE Solvers in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!