Undefined function 'C' for input arguments of type 'double'.

hello!
i am running into a problem with my script with this line:
whole_ts = {1:2150, 1:1928, 1:2426};
I've tried:
whole_ts = [{1:2150, 1:1928, 1:2426}];
whole_ts = (1:2150, 1:1928, 1:2426);
whole_ts = [C{1:2150, 1:1928, 1:2426}];
whole_ts = timeseries([1:2150], [1:1928], [1:2426])
this one seems the most promising:
whole_ts = [C{1:2150, 1:1928, 1:2426}];
where i am getting this error:
Undefined function 'C' for input arguments of type 'double'.
I am trying to load it into a cell like I did with the 'trs' variable which is 1x3 but 'whole_ts' has is [1:2150, 1:1928, 1:2426].
%% loading TACS
subj = {'subj01' 'subj02' 'subj03'}
trs = [2.8, 2.2, 2.2];
whole_ts = [C{1:2150, 1:1928, 1:2426}];
for k = 1:3
ts{k} = load(fullfile(D,subj{k},'ts','thalamus_ts.txt'));
whole_ts = 1:length(ts{k})
t_mr_1 = (1:length(whole_ts))*(trs(k)/60)
subplot(3,1,k), hold on
plot(t_mr_1, ts{k})
end
Any help would be much appreciated!

8 commentaires

Not sure why you are placing a 'C' into your code. Since C does not appear to be a predefined variable, MATLAB assumes that it is a function. However based on the naming, I doubt that you are actually trying to call a function and that it is has been placed in your code by mistake.
whole_ts = [C{1:2150, 1:1928, 1:2426}]; % Invalid syntax and also no need to use [] outside of {}.
Using [] in MATLAB creates a numeric array, {} creates a cell array. Each element in a numeric array need to be a scalar value, where elements in a cell array can consist of various types of data and not just numerical scalars. In the example below there are three elements in the cell array whole_ts, where each elements consists of a numerical array and more specifically for this instance numerical vector arrays.
whole_ts = {1:2150, 1:1928, 1:2426};
Also, can you provide an explanation to why you are defining whole_ts outside of the for-loop and again each iteration of your loop? Does your code perform as expected when removing the usage of whole_ts before your for-loop?
whole_ts = [C{1:2150, 1:1928, 1:2426}]; % Tries to initially define whole_ts but with an error
for k = 1:3
ts{k} = load(fullfile(D,subj{k},'ts','thalamus_ts.txt'));
whole_ts = 1:length(ts{k}) % Re-defines whole_ts each loop iteration
t_mr_1 = (1:length(whole_ts))*(trs(k)/60)
subplot(3,1,k), hold on
plot(t_mr_1, ts{k})
end
whole_ts = [C{1:2150, 1:1928, 1:2426}]; % Invalid syntax and also no need to use [] outside of {}.
That is not invalid syntax, and the [] is meaningful. C{range,range,range} is cell expansion if C is a cell; cell expansion is creating a comma-separated list, and then the [] is horzcat() of that comma-separated list. Entirely valid code (though it is not clear that it is what the user was wanting to do.)
Hello!
Thank you both!
Walter, I am trying to time time intervals that I then can use to plot out the time verses the timeseries.
See below:
This is what used to work if all subjects have the same x axis (see line %2) where I am plotting the thalamus timeseries against the time (whole_ts). I am doing this because I have to convert a the time because I have to take in account the TRs (sampling rate for neuroimaging) and then convert to minutes.
subj = {'sub01' 'sub02'} %1
whole_ts = 1:2150 %2
for k = 1:3
ts{k} = load(fullfile(D,subj{k},'ts','thalamus_ts.txt'));
whole_ts = 1:length(ts{k})
t_mr_1 = (1:length(whole_ts))*(trs(k)/60)
subplot(3,1,k), hold on
plot(t_mr_1, ts{k})
end
I am trying to make a script where I can put in different values for the x axis for different subjects, e.g. if I have three subjects with the corresponding time values:
1:2150, 1:1928, 1:2426
Hopefully that's more clear, and thanks a ton!
So I thought I fixed the problem, but actually I didn't.
Any help would be much appreciated
now i i have gotten the top part to work, but I am having a hard time plotting the variables now:
for k = 1:length(subj)
ts{k} = load(fullfile(D,subj{k},'ts','thalamus_ts.txt'));
whole_ts{k} = 1:length(ts{k})
t_mr_1{k} = ((1:length(whole_ts))*(trs(k)/60))
subplot(3,1,k), hold on
plot(t_mr_1{k},ts{k}) %now i cannot plot this as a graph
end
What would be the difference compared to your existing code where you compute (1:length(whole_ts)) ?
I don't think anything really, except that for some reason this:
whole_ts = [C{1:2150, 1:1928, 1:2426}];
is telling me that indexing is not supported with the C function.
do you have any suggestions on how to plot indexes:
plot(t_mr_1{k},ts{k}) %now i cannot plot this as a graph
I am getting an error that says the the vectors are not the same length, although they are.
Where did you get the C part from? Why are you expecting it to be there?
whole_ts = {1:2150, 1:1928, 1:2426};
Your file looks like it might be a 2D array instead of a vector. If so then you have to be very careful when you use length() as length(X) is defined as:
temporary = size(X);
if any(temporary == 0)
length is 0
else
length is max(temporary)
end
That is, length is 0 if any dimension is 0, and otherwise length is the largest dimension, no matter which one it is.
However, when you ask to
plot(t_mr_1{k},ts{k})
then if ts{k} is a 2D array, then MATLAB would try to plot every column as a separate line, and the length of t_mr_1{k} would have to be the same as the number of rows in ts{k} .

Connectez-vous pour commenter.

Réponses (0)

Catégories

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

Community Treasure Hunt

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

Start Hunting!

Translated by