无法写入Excel(Matlab)

当我尝试将我的代码的输出写入Excel电子表格时,出现以下错误:“未定义variables结果”或类“results.xlsx”。我似乎无法理解为什么会出现这种情况。

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 

您需要将文件名放在引号( '' )中:

 xlswrite('results.xlsx', final_matrix);