How to assign the data to the header with units in square bracket.?

Hello,
I would like to assign the data to the headers which has its units in a square bracket.
Header = 'accel [m/s²]';
Data = {1 2 3 4}',
value.Header = Data;
but I got error as Invalid field name: 'accel [m/s²]'.
How can I assign the data to header.
Please give me an idea.
Thanks
meera

 Réponse acceptée

What about
header.data = 1:4;
header.label = 'accel [m/s²]';

3 commentaires

hello Thorsten,
I have so many headers and data. Even I need to plot them.
I have labels like
Headers = {'accel1[m/s²]', 'accel2[m/s²]', 'pitch[°/s]', 'pitch Mean [°/s]'};
data = { {1 2 3 4}, {5 6 7 8}, {9 10 11 12} {13 14 15 16}}
Is there any possibility to assign the data
len = size(headers);
for i = 1:len(1,2)
value.Headers{1,i} = data(:,i);
end
later i would like to plot graph like
plot(value.Headers(1,2),value.Headers(1,3)
This is only in one file.. but I have so many such files.. where I need to replace again in future
value.Headers{m,j} = data(1,j)
please can you give me an idea
Meera
Frankly I have some problems to understand the organization of your data and what you would like to plot and why you need to assign the data to some other variables.
If you just want to plot the data, you can do it like this:
plot(cell2mat(data{2}), cell2mat(data{3}))
xlabel(Headers{2})
ylabel(Headers{3})
Meera, thank you for attempting to format your code. It turns out, though, that the '{} Code' button on the forum has nothing to do with putting '{' before and '}' after the code. Instead the forum detects code by there being an empty (or whitespace-only) line before the code, and then that the code is indented by two spaces, and then an empty (or whitespace-only) line after the code. There is a marginally different feature if the lines are indented by one space instead of two and basically if you use that then no-one will notice the difference. But the easiest thing to do is put in your code, highlight it, and click on the '{} Code' button, which will put in the spaces for you.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Variables dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by