フィルターのクリア

getting error creating coefficient matrix for cramers rule

3 ビュー (過去 30 日間)
RB
RB 2018 年 12 月 11 日
回答済み: Koundinya 2018 年 12 月 14 日
I am implementing Cramer's Rule into MATLAB and I am stuck on the coefficient matrix part as it gives me an error
% for size of matrix
n=input('');
% co-efficient matrix
coef=zeros([n n]);
and then I get an error stating that I need real integers for the zeros function
Does anyone know how to fix this? Thanks in advance.
  1 件のコメント
Matt J
Matt J 2018 年 12 月 11 日
編集済み: Matt J 2018 年 12 月 11 日
Works fine for me, as long as a positive integer is entered, e.g.,
>> % for size of matrix
n=input('');
% co-efficient matrix
coef=zeros([n n]);
5
>> coef
coef =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

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

回答 (1 件)

Koundinya
Koundinya 2018 年 12 月 14 日
The zeros function takes array dimensions as input and returns an array of zeros.
% co-efficient matrix
coef=zeros([n n]);
Here coef would be an array of size nxn with all elements equal to zero.The dimensions of an array need to be integers (array dimesion can be 0 as well). The error you get is mostly because you're inputting a non-integer value for n.

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by