Hi all, I want to be a able to paste data in any column all at once not cell by in MATLAB APP table.

조회 수: 6 (최근 30일)
T_Fixed = table(StartDates_Fixed,EndDates_Fixed,PaymentDates_Fixed,Notional,fixedrate);
app.Details_Fixed.Data = T_Fixed;
app.Details_Fixed.ColumnEditable =true(1,5);
  댓글 수: 1
dpb
dpb 2025년 9월 4일
이동: dpb 2025년 9월 4일
T_Fixed = table(StartDates_Fixed,EndDates_Fixed,PaymentDates_Fixed,Notional,fixedrate);
Unrecognized function or variable 'StartDates_Fixed'.
app.Details_Fixed.Data = T_Fixed;
app.Details_Fixed.ColumnEditable =true(1,5);

댓글을 달려면 로그인하십시오.

답변 (2개)

dpb
dpb 2025년 9월 4일
편집: dpb 2025년 9월 4일
Haven't tried it, but if it is possible, it will be something on the order of
...
tbl=uitable(app.Figure,'Data',T_fixed); % set position, etc., to suit...
tbl.SelectionType='column';
tbl.Multiselect='off'; % select only one column at a time...
tbl.SelectionChangedFcn=@pasteData; % will need other code to ensure have content in clipboard
% Paste clipboard contents for the selected column -- error checking for
% size, type, etc., etc., left as exercise for Student <g>
function pasteDate(src,event)
column=event.Selection;
data=clipboard('paste'); % return clipboard content to local variable
% check size, type here; will have to convert text to numeric as well first
data=convertandverify(data); % whatever it takes goes in here...
src.Data{:,column}=data; % put into selected column; must be cell array
end
Undoubtedly the above won't work first time, but should be the idea if it can be managed to be done...

Ali AlMallah
Ali AlMallah 2025년 9월 6일
% Get selected indices
if isempty(event.Indices)
return;
end
row = event.Indices(1,1);
col = event.Indices(1,2);
% Try to grab clipboard text
clipText = clipboard('paste');
if isempty(clipText)
return;
end
% Split clipboard text into lines
clipLines = strsplit(strtrim(clipText), {'\r','\n'});
nRows = min(numel(clipLines), size(app.Details_Fixed.Data,1)-row+1);
for i = 1:nRows
thisValue = strtrim(clipLines{i});
if col <= 3
% First three columns are dates
newVal = datetime(thisValue);
elseif ~isnan(str2double(thisValue)) % numeric
newVal = str2double(thisValue);
else
newVal = thisValue; % keep as string if neither
end
% Update table (curly indexing since it's a MATLAB table)
app.Details_Fixed.Data{row+i-1, col} = newVal;
app.updateCashflowsFromDetails();
end

Community Treasure Hunt

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

Start Hunting!

Translated by