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 件のコメント
Allen
2021 年 3 月 2 日
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
Walter Roberson
2021 年 3 月 2 日
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.)
nines
2021 年 3 月 3 日
nines
2021 年 3 月 3 日
nines
2021 年 3 月 3 日
Walter Roberson
2021 年 3 月 3 日
What would be the difference compared to your existing code where you compute (1:length(whole_ts)) ?
nines
2021 年 3 月 3 日
Walter Roberson
2021 年 3 月 3 日
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} .
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!