Using Arrayfun for iterative plotting
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Manuel Arcangeletti
il 15 Mag 2019
Commentato: Manuel Arcangeletti
il 16 Mag 2019
Hi all,
I'm trying to plot all the elements of a cell array using the command arrayfun instead of a for loop.
My cell array is the following:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/219723/image.png)
It gives me error when I use this sintax:
arrayfun(@(x)plot(repmat(x{6,2:end},1,x{2,2:end}),x{7,2:end},Gen_Array))
Can anybody please help me with this?
Thank you very much,
Manuel
4 Commenti
Risposta accettata
Jan
il 16 Mag 2019
Modificato: Jan
il 16 Mag 2019
For example:
for iRow = 1:2
plot(Gen_Array{7,2}(:, iRow), Gen_Array{7,3}(:, iRow));
end
I do not understand completely, what you want to plot:
"the first row af all the columns of my Gen_Array (name of my array){7,2} ,Gen_Array{7,3}, ..., Gen_Array{7,end}" - These are too many inputs for a plot() command, but maybe you can adjust me code to your needs.
arrayfun is an extremely compact method to avoid loops in the code. Internally the data are processed in loops also, so there is no real benefit for the execution. Use loops to follow the KISS concept: Keep it simple stupid.
Più risposte (0)
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!