Azzera filtri
Azzera filtri

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?

2 visualizzazioni (ultimi 30 giorni)
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.

Risposte (1)

Jyotish Robin
Jyotish Robin il 14 Mar 2017
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.

Categorie

Scopri di più su Data Import from MATLAB in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by