Error using ==> disp and Error in ==> TempArray1 at 6 disp('New B is equal to',D);
1 回表示 (過去 30 日間)
古いコメントを表示
I wrote two simple m files as follow trying to overwrite the values of B by the values of A. In other words, my intention is to ultimately have B as [1 2 3 4] by rewriting the matrix A to B. The reason that I have utilized two m file is that later on I need to implement such system to another problem in which the main m file has to be run with modified values of B in each step of loop. First m file as: disp('A is [1 2 3 4]'); disp('B is [4 3 2 1]'); A=[1 2 3 4]; B=[4 3 2 1]; D=TempArray2(A,B); disp('New B is equal to',D); Second m files as: function D=TempArray2(s1,s2) s2=s1; D=s2; But I again got another error message as : ??? Error using ==> disp Too many input arguments.
Error in ==> TempArray1 at 6 disp('New B is equal to',D);
Do u know the solution to this problem?
0 件のコメント
回答 (1 件)
Fangjun Jiang
2011 年 9 月 10 日
disp() is used to quickly display a text or array. You can't combine two together. In your example, use:
disp('New B is equal to');
disp(D);
or use fprintf
fprintf('New B is equal to %f%f%f\n',D);
参考
カテゴリ
Help Center および File Exchange で Communications Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!