Info
この質問は閉じられています。 編集または回答するには再度開いてください。
I have 5 data sets that I want to do calculations to and then plot separatly. Im trying to find a way to do these calculations without retyping my math 5 times with different variables each time. Is there a relativly easy way to do this?
1 回表示 (過去 30 日間)
古いコメントを表示
I think the title says it all. Thanks!
0 件のコメント
回答 (1 件)
John D'Errico
2017 年 2 月 6 日
編集済み: John D'Errico
2017 年 2 月 6 日
Write your operations as a FUNCTION.
doc function
Save the function as a separate m-file on your search path.
Then just call your function 5 times.
Even better, is if you store your data in a cell array or array of structs, rather than 5 different sets of variables. Then you would need only use a loop, and you need not even write a separate function. Just put those operations inside a loop.
Best of all, read the getting started tutorials for MATLAB, where you will learn these things.
2 件のコメント
John D'Errico
2017 年 2 月 6 日
But are they an array of cell arrays? Cell arrays can be three dimensional, or they can contain other cell arrays.
The point is to use a loop. Don't store your data in separate arrays, if you will need to process each piece in one code.
この質問は閉じられています。
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!