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 个评论
But I want to get the elements in cell.These elements will be used in other part of my code.
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
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?
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.
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.
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!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 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)
