MATLAB Answers

I am trying to create a function that cuts down variables within a structure that are defined in a parameter list, but I am getting the error message "index exceeds matrix dimensions" and I'm not sure why?

2 ビュー (過去 30 日間)
SC0TT1E94 2017 年 5 月 2 日
コメント済み: Guillaume 2017 年 5 月 2 日
I'm trying to shorten certain variables contained within the input structure (in_struct) and then save the overwritten structure.
The parameters I am shortening are listed in param_list, and the limits by which I am shortening them are also defined.
The code for the function I've created is below:
function y = profile_down_cut(in_struct, outfile, param_list, lim_min, lim_max)
% Calculating the fast
for i =1:numel(param_list)
name = param_list{i}; %Selecting the parameter name from list
value = in_struct.(name); %selecting parameter data from structure
in_struct.(name) = value(lim_min:lim_max);
save(outfile, 'in_struct', '-v7.3')
You'll notice that I have a keyboard in the script - the line below is where the code is failing and giving me the error: "index exceeds matrix dimensions".
I've attached a screenshot of my workspace at the keyboard. I have given a shortened version of the function, so the names are slightly different and I actually have to shorten two sets of parameters... Interestingly, the code works when I shorten the length of my fast param_list from 30 to 12 (13 and above don't work).
Thanks in advance for your help.

  1 件のコメント

Guillaume 2017 年 5 月 2 日
What is size(value) and the actual value of lim_min and lim_max at the point where it fails.
Hint: use dbstop if error to automatically break into the debugger when the error is thrown.

サインイン to comment.

回答 (0 件)

サインイン してこの質問に回答します。

Translated by