Undefined operator '-' for input arguments of type 'struct'.

5 ビュー (過去 30 日間)
Amy Leach
Amy Leach 2020 年 1 月 7 日
回答済み: Cris LaPierre 2020 年 1 月 7 日
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 件のコメント
Allen
Allen 2020 年 1 月 7 日
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?
Amy Leach
Amy Leach 2020 年 1 月 7 日
Yes, Ts is defined earlier with this:
%Create Variables for each Photometry Channel and timestamps
Ch473=data.streams.x473A.data; %GCaMP
Ch405=data.streams.x405A.data; %Isosbestic Control
Ts = ((1:numel(data.streams.x473A.data(1,:))) / data.streams.x473A.fs)'; % Get Ts for samples based on Fs
StartTime=3000; %Set the starting sample(recommend eliminating a few seconds for photoreceiver/LED rise time).
EndTime=length(Ch473)-1000; %Set the ending sample (again, eliminate some).
Fs=data.streams.x473A.fs; %Variable for Fs
Ts=Ts(StartTime:EndTime); % eliminate timestamps before starting sample and after ending.
%Ch473=Ch473(StartTime:EndTime);
%Ch405=Ch405(StartTime:EndTime);

サインインしてコメントする。

回答 (1 件)

Cris LaPierre
Cris LaPierre 2020 年 1 月 7 日
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));

カテゴリ

Help Center および File ExchangeData Type Identification についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by