Parse error at values
古いコメントを表示
function [m,s] = inputtrial(x)
n = length(x);
m = avg(x,n);
s = sqrt(sum((x-m).^2/n));
end
function m = avg(x,n)
m = sum(x)/n;
end
values[] = [12.7, 45.4, 98.9, 26.6, 53.1];
[ave,stdev] = inputtrial(values)
回答 (1 件)
Ameer Hamza
2020 年 10 月 30 日
編集済み: Ameer Hamza
2020 年 10 月 30 日
In MATLAB, you can define an array like this
values = [12.7, 45.4, 98.9, 26.6, 53.1];
% values[] is a syntax error
2 件のコメント
lopamudra singh
2020 年 11 月 1 日
Ameer Hamza
2020 年 11 月 1 日
編集済み: Ameer Hamza
2020 年 11 月 1 日
In MATLAB, the lines of code must precede the function definitions. So move the last two lines to the top
values = [12.7, 45.4, 98.9, 26.6, 53.1];
[ave,stdev] = inputtrial(values)
function [m,s] = inputtrial(x)
n = length(x);
m = avg(x,n);
s = sqrt(sum((x-m).^2/n));
end
function m = avg(x,n)
m = sum(x)/n;
end
カテゴリ
ヘルプ センター および File Exchange で MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!