Info
この質問は閉じられています。 編集または回答するには再度開いてください。
after writing my script and running it, it is only returning the file name with no error meaage. What is the problem here?
1 回表示 (過去 30 日間)
古いコメントを表示
I wrote a script to solve an integral and saved it under CP1. After clicking run, it only returns the file name "CP1" with out any kind of error message. What is the problem here?
wt = [1,4,2,4,2,4,1];
L = 3;
amp = 1;
type = 1;
n = 5;
h = L/(n-1);
wt = wt*(h/3);
Int = 0;
for i=1;n;
x = L*(i-1)/(n-1);
p = amp*LoadFunctionCP(x,L,type);
Int = Int + wt(i)*p;
end
1 件のコメント
Image Analyst
2018 年 5 月 20 日
編集済み: Image Analyst
2018 年 5 月 20 日
What do you consider to be the output of that script? A variable? A file? It's not clear what you think the output should be.
What do you mean by "return"? Do you really want a function instead of a script and want some main program to call that function and have the function return the output in some variable? Or do you simply want your script to keep the variable in the base workspace (like it is now)? Or do you want some file, like a .mat or .xlsx file?
Maybe you want to tell the user what Int is? Like this
message = sprintf('Int = %f', Int)
uiwait(helpdlg(message));
回答 (1 件)
JAYANTH BHIMAVARAPU
2018 年 5 月 21 日
編集済み: JAYANTH BHIMAVARAPU
2018 年 5 月 21 日
Generally this message appears when we try to run an empty script or a complete script which is not printing anything In your case the second one was little valid.
The for loop syntax was for i=1:n and not for i = 1;n
So your loop will execute only once and will call LoadFunctionCP(0,3,1) once not 5 times as expected. So please modify your code with these changes.
So based on your function definition you can now check whether you want to print anything or not. You can always do this by just removing the semicolon at the end of that particular statement.
If everything was fine you can just check the content of Int variable manually by double clicking on it in workspace. Hope this helps you.
0 件のコメント
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!