How can I fix this error?
古いコメントを表示

4 件のコメント
Khalid Mahmood
2021 年 4 月 7 日
Your question is not clear. What is i?
Khalid Mahmood
2021 年 4 月 7 日
編集済み: Khalid Mahmood
2021 年 4 月 7 日
%Supposed this
function y=Question5(x,i)
.....
end
Let, x=randi([-10 10],5,3)
y=Question5(x,3)
Hazal Yuvgun
2021 年 4 月 7 日
Hazal Yuvgun
2021 年 4 月 7 日
採用された回答
その他の回答 (2 件)
Steven Lord
2021 年 4 月 7 日
0 投票
Where in your code do you define a variable named i? If the answer is some form of "nowhere" or "I don't" then MATLAB will call the built-in function to determine the value that should be used. That built-in function returns neither a positive integer value nor a logical value.
Khalid Mahmood
2021 年 4 月 7 日
function y=Question5(x,i)
y=[];
if i==1
y=x(1,:);
else
y=x(i,:)-x(1,:);
end
end
1 件のコメント
Khalid Mahmood
2021 年 4 月 7 日
save above code as Question5.m file. Then
>>x=randi([-10 10],5,3); % define x, or whatever x you want
>>y=Question5(x,1)
>>y=Question5(x,2)
>>y=Question5(x,3)
But I think you may need following code for advanced logic.
カテゴリ
ヘルプ センター および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!