Getting a for loop to save a plot every step

1 回表示 (過去 30 日間)
HC98
HC98 2019 年 12 月 2 日
回答済み: Star Strider 2019 年 12 月 2 日
Good evening,
I'll keep this brief but I'm looking to see how I can write a for loop which takes a range of constants, applies them to an equation and plots the output after ach step. Is there a way to do this without manually defining a new equation and using hold on?

回答 (1 件)

Star Strider
Star Strider 2019 年 12 月 2 日
Use the same equation and pass the different parameters as extra parameters in a loop. See the documentation secton on Passing Extra Parameters to understand how to do this. Then use one or more loops to select the parameters at each iteration. How you choose to plot them — in a single axis using hold or as subplots (or using the stackedplot function) — is your choice.
A very efficient way to do this is to use the ndgrid or meshgrid function to create matrices of the parameters, then reshape them to column vectors (using reshape or the (:) subscript convention). That way, you can use one loop to use all combinations of your parameters.

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by