Error when storing data after forloop

I want to calculate the derivative of RHEE. I also created 2 for loops. I want to store each derivative for each test. But it gives the following error : ()-indexing must appear last in an index expression.
aantal_proefpersonen = length(data_stair_rise);
for welke_pp=1:aantal_proefpersonen %forloop for 5 subjects
switch welke_pp
case 1
case 2
case 3
case 4
case 5
end
for i_testen=1:length(data_stair_rise) %forloop for all measurements per subject
RHEE = data_stair_rise(welke_pp,i_testen).VideoSignals(:, strcmp('RHEE', data_stair_rise(welke_pp,i_testen).VideoSignals_headers)); %data extraction
RHEE = d.RHEE;
T = 0:size(RHEE)-1;
dRHEE(welke_pp,i_testen) = gradient(welke_pp,i_testen)(RHEE,T); %want to store each derivative (error)
end end

6 Comments

Sam - does gradient correspond to this function http://www.mathworks.com/help/matlab/ref/gradient.html, or to something else? If the former, then shouldn't the first input be a vector and not a scalar? Please confirm that your use of gradient is correct and explain what you are attempting to do with the line
dRHEE(welke_pp,i_testen) = gradient(welke_pp,i_testen)(RHEE,T);
What do the variables mean to you, and why are you indexing the return of gradient? Also, why does your code have a switch with case statements that do nothing?
I just want to switch between the subjects. First subject1, than 2, 3, 4 and 5. I thought it wasn't necessary to put something under the case-expressions?
"I just want to switch between the subjects." &nbsp What exactly do you want to achieve?
I got 5 subjects. Case 1 is my first subject. In debug mode it goes from case 1 to the next for loop. After that for loop it jumps to case 2, and then again to the next for loop. And so on... So I can run the program for 5 subjects and all their measurement... Correct?
Geoff Hayes
Geoff Hayes on 28 Dec 2014
Edited: Geoff Hayes on 28 Dec 2014
Sam - since there is no code for any of your cases, then there is no need for it, so you may as well remove it. Please see Per's links to the details of switch.
Also, please answer my previous questions concerning your use of gradient.
I'm just so lost with all the non-English words and bad formatting that I'm not even attempting to understand what's going on there. It's too confusing. Sorry. Plus it looks a lot like your other questions so I don't know what's different here as compared to all the other questions. Good luck though.

Answers (0)

This question is closed.

Tags

Asked:

Sam
on 27 Dec 2014

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!