0
當我嘗試將代碼的輸出寫入Excel電子表格時,出現以下錯誤:「未定義變量」結果「或類」results.xlsx「。要理解爲什麼會出現這種情況無法寫入Excel(Matlab)
function [final_matrix] = MCsolutionupdated()
no_iterations = input('No. of iterations?:');
thresh_strain = zeros(1,no_iterations*16);
casechoice =input('Enter 1 for 1st Layup and 2 for 2nd layup:');
J = Nielsennewupdated(casechoice, no_iterations);
thresh_strain = J;
roundedValues = round(thresh_strain/.0001)*0.0001;
myUniqueValues = unique(roundedValues);
i = numel(myUniqueValues);
nelements = hist(thresh_strain(:),myUniqueValues);
for i=1:i
percent(i) = (nelements(1,i)/numel(thresh_strain))*100;
end
final_matrix = [myUniqueValues' percent'];
xlswrite(results.xlsx, final_matrix); % Problem
這是一個非常愚蠢的錯誤感謝 – Jojo
荒謬的錯誤發生,我的愛幫助文檔,獲取示例代碼並使其運行,然後稍微改變它,然後重複完成後,你自己的代碼就可以工作了,而且花費的時間也更少。它需要更少的時間,因爲你可以避免愚蠢的錯誤。 http://www.mathworks.com/help/matlab/ref/xlswrite.html – EngrStudent