use variable in for loop as function output
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Hi, I want to use gg{m} as my function output, how can i do?
採用された回答
Ameer Hamza
2018 年 5 月 9 日
編集済み: Ameer Hamza
2018 年 5 月 9 日
function [ gg{m}] = mykmeans()
shows (although this syntax will not work) that you want to pass only one element to output. Instead, use
function [ gg] = mykmeans()
to pass the whole array.
8 件のコメント
Frank Juang
2018 年 5 月 9 日
But I want to get the elements in cell.These elements will be used in other part of my code.
Ameer Hamza
2018 年 5 月 9 日
You can still get the element. For example, you call the function like this
% your script
gg = mykmeans(); % you call your function
gg{1} % access the first elemnet by indexing
gg{2} % similarly other elements
Frank Juang
2018 年 5 月 9 日
Thank you !!
function [ gg{m}] = mykmeans()
"will only pass one element to output"
@Ameer Hamza: Have you tried this syntax? What actually happened? Can you show any documentation or example where that statement is true?
Frank Juang
2018 年 5 月 9 日
If I use
% function [ gg{m}] = mykmeans()
, it will occur error :invalid syntax at '{''Possibly a ), }, ] is missing ...
@Frank Juang: don't worry, that syntax is not supported, even if Ameer Hamza (incorrectly) wrote that it is.
Ameer Hamza
2018 年 5 月 9 日
Oh! I meant to say that, OP just want to pass one element to output, why not pass the whole array. But the wording got incorrect.
Frank Juang
2018 年 5 月 9 日
that's all right
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Creating, Deleting, and Querying Graphics Objects についてさらに検索
参考
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)
