Creating a function that returns a graph

Hello.
I have to study the displacement of a sheet pile. At end of computation, I have matrices of size (N_ELEMENTS,N_TIME), for each degree of freedom and for time. I'm making a plot animation (with a plot into a loop). But this plot will be used in other codes, so instead of copy/paste I would like a function []animation = (...) that gives the plot.
In my code I will then have :
. . . animation(t,water_height,disp_nodes,N,NDoF,size_el,1); . . .
But I have this error : ??? Subscript indices must either be real positive integers or logicals.
Maybe someone know how to call this function properly ? Thanks !

 採用された回答

Image Analyst
Image Analyst 2013 年 11 月 29 日

0 投票

Find out which index has a fractional part or is negative by using this link: http://blogs.mathworks.com/videos/2012/07/03/debugging-in-matlab/.
"[]animation = (...)" is not valid syntax. This would be valid:
To call in the main function
results = animation(t,water_height,disp_nodes,N,NDoF,size_el,1);
To declare the function:
function results = animation(t,water_height,disp_nodes,N,NDoF,size_el, someFlag)
% Code for it follows...
It also looks possible that MATLAB might think your animation is a 7 dimensional array rather than a function , which would happen if animation function was not declared or was out of scope or was not on the search path.

1 件のコメント

Freddy
Freddy 2013 年 11 月 30 日
Thanks it works. The problem was exactly what you mentioned at end, Matlab understood "animation" as a variable, and I had the error of indices because of the different sizes of arguments of the function.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeAnimation についてさらに検索

質問済み:

2013 年 11 月 29 日

コメント済み:

2013 年 11 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by