error to get the answer by Kronecker

function K = kronecker(A,B)
if ~issparse(A) && ~issparse(B)
if ~ismatrix(A) || ~ismatrix(B)
error('kronecker:TwoDInput','Inputs must be 2-D.');
end
% Both inputs are full, result is full. This is faster than
% MATLAB stock kron (indexing based)
[ma, na] = size(A);
[mb, nb] = size(B);
A = reshape(A,[1 ma 1 na]);
B = reshape(B,[mb 1 nb 1]);
K = bsxfun(@times,A,B);
K = reshape(K,[ma*mb na*nb]);
else % One of the input matrix is sparse
% Call MATLAB stock KRON
K = kron(A,B);
end
how can i solve the error ?

6 件のコメント

KSSV
KSSV 2019 年 5 月 1 日
What input you tried? Waht error you get?
Walter Roberson
Walter Roberson 2019 年 5 月 1 日
What error? You have not shown us any error message, and you have not shown us how you are calling this or what the size() or class() of the inputs are.
imrankhan ajees
imrankhan ajees 2019 年 5 月 1 日
need more details about the error what is shown???
Mariam Gasra
Mariam Gasra 2019 年 5 月 1 日
lamda=0.2
mu=1-lamda
A=[-(lamda1+lamda2) mu2 mu1 0;lamda2 -(mu2+lamda1) 0 mu1;lamda1 0 -(lamda2+mu1) mu2;0 lamda1 lamda2 -(mu1+mu2)];
B=[1;0;0;0];
Walter Roberson
Walter Roberson 2019 年 5 月 1 日
Undefined variables lamda1, lamda2, mu1, mu2
You set variables lamda and mu but you do not use them.
You still have not indicated what error you are observing.
imrankhan ajees
imrankhan ajees 2019 年 5 月 1 日
copy the content on the command window after getting the error and post it otherwise we can't help you

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

製品

タグ

質問済み:

2019 年 5 月 1 日

コメント済み:

2019 年 5 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by