Undefined operator '-' for input arguments of type 'struct'.
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm trying to edit a program that analyzes change in fluorescence occuring around TTL inputs. I keep getting the following error and am not sure how to fix it:
Undefined operator '-' for input arguments of type 'struct'.
Error in Magazine_training (line 28)
[c, ind] = min(abs(Ts-data.epocs.PtC1(TTL_index, 1))); %returns the position best fit between T and Po0 onset
Here's the portion of code producing the error:
%Takeing TTL times and Delta473 values around TTLs
%data.epocs.PtC1_.onset - Pellet drop
TTL_size = numel(data.epocs.PtC1);
TTL_times = zeros(TTL_size:1);
TTL_temp = zeros(TTL_size:1);
interval_pre = -2000; %milliseconds
interval_post = 15000; %milliseconds
interval_count = abs(interval_pre) + abs(interval_post);
TTL_signal = zeros(interval_count, TTL_size);
for TTL_index = 1:TTL_size %% timestamp
[c, ind] = min(abs(Ts-data.epocs.PtC1(TTL_index, 1))); %returns the position best fit between T and Po0 onset
position = 0;
for interval_ind = interval_pre:interval_post
position = position+1;
TTL_signal(position, TTL_index) = Delta473(ind + interval_ind);
end
TTL_temp(TTL_index) = Delta473(ind); %writes the Delta473 value for the best T+Po0 position
TTL_times(TTL_index) = ind;
end
plot(TTL_signal,'DisplayName','TTL_signal')
csvwrite('pelletdrop.csv',TTL_signal);
2 Kommentare
Allen
am 7 Jan. 2020
From line 28 that is producing the error, have you defined Ts? If so, can you provide details about Ts such as variable type and/or size?
Antworten (1)
Cris LaPierre
am 7 Jan. 2020
Here's a simple case that reproduces the error message
Ts = 10;
data.val = 5;
Ts-data
Undefined operator '-' for input arguments of type 'struct'.
The problem is that data is a structure, not a value. I need to add .val for the code to execute as intended
Ts-data.val
ans =
5
I therefore recommend inspecting you structure data to see if you inadvertantly left off a field name. Perhaps it should be something like this?
[c, ind] = min(abs(Ts-data.epocs.PtC1(TTL_index, 1).val));
0 Kommentare
Siehe auch
Kategorien
Mehr zu Data Type Identification finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!