MATLAB Answers

naming using a string function

조회 수: 1(최근 30일)
Ayman Mounir
Ayman Mounir 2021년 1월 7일
편집: Stephen Cobeldick 2021년 1월 7일
Hello everyone,
I have let's say : x=' a name' ; and B= [1 2 3],
and I want to create a variable ' a name' = B whiche is [1 2 3], in another word i want to create a variable using the string of another variable (example filename='Hallo' the 'Hallo'= B=[1 2 3],
So, I tried to use [x]=B; but it does not work;
  댓글 수: 3
Stephen Cobeldick
Stephen Cobeldick 2021년 1월 7일
@Ayman Mounir: your save usage makes no sense.
The first input argument of save must be a filename, so why are you providing a table as the first input?
The second input is usually the name of the variable to be saved, it is not clear what you expect the character vector 'standard_name' to achieve. I recommend that you read the save documentation, it explains how to use save.
In any case, magically defing variable names is unlikely to be a suitable solution to ... whatever you problem might be.

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

답변(2개)

Catalytic
Catalytic 2021년 1월 7일
s.(x)=B
  댓글 수: 1
Ayman Mounir
Ayman Mounir 2021년 1월 7일
thanks, but without creating a structure

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


Stephen Cobeldick
Stephen Cobeldick 2021년 1월 7일
편집: Stephen Cobeldick 2021년 1월 7일
The MATLAB approach:
N = numel(files);
C = cell(1,N);
for k = 1:N
F = fullfile(files(k).folder,files(k).name);
C{k} = readtable(F);
end
dataname = vertcat(C{:});
save('some_file_name.mat', 'dataname')

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by