??? Subscript indices must either be real positive integers or logicals.
情報
この質問は閉じられています。 編集または回答するには再度開いてください。
古いコメントを表示
hi, i'm using m file in cell mode to solve f(x)=sin (x), where x = 0.8 and i'm getting "??? Subscript indices must either be real positive integers or logicals. " error how it can be solved
1 件のコメント
Gijs van Oort
2013 年 5 月 6 日
Please tell us the exact code you're using. Is it actually Matlab code? The code you're giving ('solve f(x)=sin(x)' ) is not Matlab compatible.
回答 (2 件)
Is this what you're trying to do?
%%Don't run this part
A = magic(4);
%%Run this part by itself
x = 0.8;
f = sin(x)
%%Not this part
A = rand(4);
What you do is: Place your cursor in the middle section. Then press Ctrl + Enter.
Please watch this video:
7 件のコメント
ghassan
2013 年 5 月 6 日
There is no difference. Write the two lines in an M-file, save it and run it (either press F5, or write the name of the file in the command window in matlab). If you for some reason want a function (which doesn't make much sense, since it is built-in):
function f = calculate_sin(x)
f = sin(x);
end
Then run the function from Matlab:
f = calculate_sin(0.8);
ghassan
2013 年 5 月 6 日
Check my updated answer: I assume you have a script that does more than one thing.
What you do is: Insert %% above the part of the code you want to run, and below it.
Press Ctrl + Enter, when your cursor is in your desired section. And that's that.
Please watch this video:
ghassan
2013 年 5 月 6 日
ghassan
2013 年 5 月 6 日
Jan
2013 年 5 月 6 日
Please, ghassan, format your code properly. Follow the "? Help" link to learn how to use the forum's interface. Thanks.
It would be helpful, if you post the complete error message and explain, in which line the problem occurres. Then we do not have to guess the details.
It is more complicated to answer to information, which is provided in the comment section. Please collect all required information in the original question, for this reason editing the questions has been introduced in this forum.
この質問は閉じられています。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!