Rerun script with different table input

조회 수: 1 (최근 30일)
Lukas Netzer
Lukas Netzer 2021년 5월 5일
댓글: Lukas Netzer 2021년 5월 5일
Hey,
I wrote quite a long script, that uses table data, like so:
Location = table1.Location;
Is there a way to replace "table1" in all lines of the script and replace it e.g. with table2? To get:
Location = table2.Location;
Additionally I'm relying on tablesizes in my script (probably not a good way to do that) but I manually entered e.g.:
sh(1:2734) = sh;
where (1:2734) represents the table size. Is there a way to have the following?
sh("tablesize") = sh
Thanks for your help!
  댓글 수: 3
Lukas Netzer
Lukas Netzer 2021년 5월 5일
Hey Emir,
thanks for your response, this is actually something I need right now but I do not get that pop-up when replacing table1 with t{n}.. Maybe I can do it with one of those options? -->:
Lukas Netzer
Lukas Netzer 2021년 5월 5일
Allready got it! I did it with find and replace ;))

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

채택된 답변

David Hill
David Hill 2021년 5월 5일
You should always attempt to index. Put all your tables into a single cell array.
t{1}=table1;
t{2}=table2;
%then index into t
n=2;
Location=t{n}.Location;
sh(size(t{n}))=sh;%not sure what you are using this for, but size() gives the size of the table

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by