- http://www.mathworks.com/help/matlab/text-files.html (How to load text files)
- https://www.mathworks.com/help/matlab/ref/xlsread.html#bthf_dr (How to read excel files)
how to the save value of variable obtained in iterative process when we input the value of the variable from txt file or excel file?
1 回表示 (過去 30 日間)
古いコメントを表示
function sum_b = fcn(c)
%#codegen
sum_b=0;
for ii=1:length(c)
sum_b=sum_b+c(ii);
disp(sum_b);
end
end
This works perfectly fine when i specify c=1:10,but when i am taking the value from outside,it's not giving me a perfect output.Please help.
0 件のコメント
回答 (1 件)
Jyotish Robin
2017 年 3 月 14 日
Hi Smruti!
This is possibly because you may not be properly loading the data from the text or excel file to MATLAB.
You can read through the below links to know how to read these files into MATLAB workspace:
Once you load the variable to MATLAB workspace, make sure that the variable is of proper numeric data type.
Note :The input argument to the function 'length' has to be Input array, specified as a numeric array, character array, logical array, structure, cell array, categorical array, datetime array, duration array, or calendarDuration array.
Hope the above suggestions are helpful.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Import from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!