フィルターのクリア

Type of error - Subscripted assignment dimension mismatch?

4 ビュー (過去 30 日間)
Sarah  Coleman
Sarah Coleman 2012 年 4 月 20 日
In my main function,outside my for loop in which the calculations are done, I created an array:
driTable = zeros(length(A),2);
where length(A) = 5
I have a function with 2 outputs which have been formatted to 1dp within the function, and has been called in the main function:
[driInput1, driInput2] = dri_calculate( z,z2,beta,g);
This how the outputs have been calculated
driInput1 = sprintf('%4.1f',driInput);
driInput2 = sprintf('%4.1f',driInput);
driInput is calculated from:
driInput = ((beta^2)/g)*(max(z));
Once I've returned these outputs to the main function, I do this:
driTable(k,1) = driInput1;
driTable(k,2) = driInput2;
where "k" is the counter of a for-loop. At:
driTable(k,1) = driInput1;
is where I get my error message. The thing is before I did sprintf and just outputted driInput, I didn't get an error message.

採用された回答

RNTL
RNTL 2012 年 4 月 20 日
I think your variables driInput1/driInput2 are strings and not numeric. check it. if so, unless they of size one (and they are not) you will not be able to assign each of them inside single element of driTable.
  3 件のコメント
RNTL
RNTL 2012 年 4 月 20 日
>> whos driInput1
and you get that its Type is char.
you need to assign it as numeric type
Sarah  Coleman
Sarah Coleman 2012 年 4 月 20 日
I appreciate your help Ron, it worked.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by