variable size of simulink matlab function
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
function desired = path_planning(data_points,slope0,slopeF,dt)
t_dummy=0:((length(data_points))-1);
tq=0:(dt/10):((length(data_points))-1);
desired=spline(t_dummy,[slope0; data_points; slopeF],tq);
end
error "Data 'desired' is inferred as a variable size matrix, while its properties in the Model Explorer specify its size as inherited or fixed. Please check the 'Variable Size' check box and specify the upper bounds in the size field."
i am also attaching the simulink file, can you please see what is issue here? the same function works fine in matlab but not in simulink.
採用された回答
Birdman
2018 年 4 月 4 日
Run the attached model. What you basically needed to do is to go to Model Explorer and set the output of the MATLAB Function as variable size by checking the tickbox there. Also, specify the size of the output.
16 件のコメント
Syed hamza Ali Tirmizi
2018 年 4 月 4 日
Not working.... the point to think is, data_points are variable input vector, it's length will define the size of output vector.... so how can i tell the simulink it's size beforehand in model explorer?
Birdman
2018 年 4 月 4 日
It worked for me without any error. Are you sure it is not working?
Yes, you can tell it by writing
str2num(get_param('open_loop_for_matlab_edited/Constant3','Value'))
Syed hamza Ali Tirmizi
2018 年 4 月 4 日
this error pops up
Birdman
2018 年 4 月 4 日
Run this.
Syed hamza Ali Tirmizi
2018 年 4 月 4 日
same error, it seems increasing size don't matter here. Also Simulink is not handling varsize of array.
Birdman
2018 年 4 月 4 日
What is the code in your MATLAB Function?
function desired = path_planning(data_points,slope0,slopeF,dt)
t_dummy=0:((length(data_points))-1);
tq=0:(dt/10):((length(data_points))-1);
desired=spline(t_dummy,[slope0; data_points; slopeF],tq);
end
Birdman
2018 年 4 月 4 日
Add this line to your function at the very beginning. Also, check the attached figure to make sure your Model Explorer contains the necessary information.
function desired = path_planning(data_points,slope0,slopeF,dt)
desired=zeros(data_points(1),data_points(2));
t_dummy=0:((length(data_points))-1);
tq=0:(dt/10):((length(data_points))-1);
desired=spline(t_dummy,[slope0; data_points; slopeF],tq);
end
Syed hamza Ali Tirmizi
2018 年 4 月 4 日
not working, but i need to say thank you.
Birdman
2018 年 4 月 4 日
Have you checked my attached figure? Have you verified that it is the same as yours? Check for the model and block name match.
Syed hamza Ali Tirmizi
2018 年 4 月 4 日
yeah i matched that too
Birdman
2018 年 4 月 4 日
There you see your model's name is open_loop_for_matlab but in size field, the model name is open_loop_for_matlab_reedited. Erase the _reedited part to match the model name with the content of get_param. Note that they should be matching at every letter. Try this.
Syed hamza Ali Tirmizi
2018 年 4 月 4 日
they are matching now, still same error
Syed hamza Ali Tirmizi
2018 年 4 月 4 日
error
Birdman
2018 年 4 月 4 日
hamza's answer moved here:
thanks Birdman, i got a solution from this discussion. i first need to define var size where you asked me to. So it outputs the correct results.
Birdman
2018 年 4 月 4 日
You are welcome. Actually, there was nothing else I could suggest because it should have worked with the way that I suggested. Anyway, I am glad it works.
その他の回答 (1 件)
Lavanya Dachepally
2019 年 7 月 17 日
The same question but in my case I need to check that variable size and specify its size through commands.
I have connected to the function block to the model through commands and the output of the function comes into picture when I ran code which is of variable based on the input.
Please can some one help how to check the box and specify its size through some commands.
カテゴリ
ヘルプ センター および File Exchange で Interactive Model Editing についてさらに検索
タグ
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
