I have cell array g like this:
{'A'} {[1]} {[1]} {[1]}
{'B'} {[1]} {[2]} {[1]}
{'C'} {[2]} {[3]} {[2]}
{'D'} {[1]} {[4]} {[1]}
{'E'} {[1]} {[5]} {[1]}
I have M=[31,2].
How can I insert M to the first column of g.
Result should be
{31,2} {'A'} {[1]} {[1]} {[1]}
{31,2} {'B'} {[1]} {[2]} {[1]}
{31,2} {'C'} {[2]} {[3]} {[2]}
{31,2} {'D'} {[1]} {[4]} {[1]}
{31,2} {'E'} {[1]} {[5]} {[1]}

 채택된 답변

Stephen23
Stephen23 2020년 10월 12일

0 개 추천

g = g(:,[1,1:end]);
g(:,1) = {M}

추가 답변 (1개)

Matt J
Matt J 2020년 10월 12일
편집: Matt J 2020년 10월 12일

0 개 추천

g=[ repmat({M},5,1) , g]

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

질문:

NA
2020년 10월 12일

답변:

2020년 10월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by