Error using ==> mtimes Inputs must be 2-D, or at least one input must be scalar.

2 views (last 30 days)
I'm working on a data generation, The code presentes the Error Inputs must be 2-D, or at least one input must be scalar, at C=inv(A)*permute(D,[2 1 3]);
A=zeros(Ix*Iz,Ix*Iz); Matrix
B=zeros(Ix,Iz,N); Matrix
D=zeros(1,Ix*Iz,N); vector where i Store the elements of B
T=zeros(Ix,Iz,N); Elements i have to calculate
C=zeros(1,Ix*Iz,N); vector where i Store T calculated
for n=2:N
%**Le sommet (1,1)
B(1,1)=T(1,1,n-1)-(2*Q2*TG)-(2*Q1*TI);
%face latérale gauche
for j=2:Iz-1
B(1,j)=T(1,j,n-1)-(2*Q2*TG);
end
%**Le sommet (1,Iz)
B(1,Iz)=T(1,Iz,n-1)-(2*Q2*TG)-(2*Q4*TS);
%face inférieure
for i=2:Ix-1
B(i,1)=T(i,1,n-1)-(Q1*TI);
end
%le sommet (Ix,1)
B(Ix,1)=T(Ix,1,n-1)-(2*Q3*TD)-(2*Q4*TS);
%face supérieure
for i=2:Ix-1
B(i,Iz)=T(i,Iz)-(2*Q4*TS);
end
%le sommet (Ix,Iz)
B(Ix,Iz)=T(Ix,Iz,n-1)-(2*Q3*TD)-(2*Q3*TS);
%face latérale droite
for j=2:Iz-1
B(Ix,j)=T(Ix,j,n-1)-(2*Q3*TD);
end
k=1;
for i=1:Ix
for j=1:Iz
D(k)=B(i,j);
k=k+1;
end
end
s=1;
for i=1:Ix
for j=1:Iz
C(s)=T(i,j,n);
s=s+1;
end
end
C=inv(A)*permute(D,[2 1 3]);
end
I know inv(A) is 2-D and Permute(D,[2 1 3]) is considered 3-D, What i want to have is:
C(time 1)=A\D'(time 1)
C(time 2)=A\D'(time 2)
:
:
:
:
C(time N)=A\D'(time N)
But i dont know how to proceed.
  1 Comment
dpb
dpb on 4 Dec 2013
I know inv(A) is 2-D and Permute(D,[2 1 3]) is considered 3-D, ...But i dont know how to proceed....
Early on you write
D=zeros(1,Ix*Iz,N); vector where i Store the elements of B
Why did you create a 3D array to begin with to hold (apparently) some number of vectors? Why isn't D just
D=zeros(Ix*Iz,N);
and then select the column desired for the operation?
I didn't read the code to try to fully follow what you're after, so perhaps what you're looking for is really 3D but N planes of Ix_by_Iz each? In that case
D=zeros(Ix,Iz,N);
and reference the desired 2D plane by
D(:,:,n)
where n is the desired specific plane.

Sign in to comment.

Answers (0)

Categories

Find more on Operators and Elementary Operations 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!