Home > Mobile >  I keep get this error message Unable to perform assignment because value of type 'tf' is n
I keep get this error message Unable to perform assignment because value of type 'tf' is n

Time:12-21

        num = [1];
dem = [1 1 0 0];
T=[0.1,0.5,2,3,4,20];
ind='A,B,C,D,E,F'
index=strsplit(ind,',')

for i=1:length(T)
    for j=1:length(index)
        index(j)= tf(num ,dem,'Inputdelay',T(i));  %% error is here 
    end
    for plotId = 1 : 6
        subplot(3,2,plotId), bode(index(j))
        grid on;
        title(['delay=',num2str(T(plotId))])
    end
end

Blockquote problem is that i could not using index i heard about somthing call eval but i've got no idea

CodePudding user response:

Results returned from ft have many properties, you must specify which one you need :

for j=1:length(T)
        results= tf(num ,dem,'Inputdelay',T(i));  
        index(j).num =results.num; 
        index(j).den =results.den;
        index(j).Variable =results.Variable; 
        index(j).ioDelay =results.ioDelay; 
        index(j).InputDelay =results.InputDelay; 
        index(j).OutputDelay =results.OutputDelay; 
        index(j).Ts =results.Ts; 
        index(j).TimeUnit =results.TimeUnit; 
        index(j).InputUnit =results.InputUnit; 
        index(j).InputName =results.InputName; 
        index(j).InputGroup =results.InputGroup; 
        index(j).OutputName =results.OutputName; 
        index(j).OutputUnit =results.OutputUnit; 
        index(j).OutputGroup =results.OutputGroup; 
        index(j).Name =results.Name; 
        index(j).Notes =results.Notes; 
        index(j).UserData =results.UserData; 
        index(j).SamplingGrid =results.SamplingGrid;
    end

CodePudding user response:

I don't know much about TensorFlow, which is really what you are asking about, but the reason you get the error is that the type of the variable index becomes a 'cell array' when you use strsplit:

ind='A,B,C,D,E,F'
index=strsplit(ind,',')

ind =

    'A,B,C,D,E,F'


index =

  1×6 cell array

    {'A'}    {'B'}    {'C'}    {'D'}    {'E'}    {'F'}

Thus, when you try index(j) = tf(...) you are trying to put a type that is not a cell into a variable that is a cell. Matlab doesn't let you do this. For more on cell arrays: https://au.mathworks.com/help/matlab/ref/cell.html.

  • Related