Equation Error Argument to dynamic structure reference must evaluate to a valid field name

2 次查看(过去 30 天)
Ft.(kk)= log((k.*y.*r.^2).*(sqrt(((4*zetasq*(r.^2.)+1))./(((1-(r.^2).^2)+(4*zetasq*(r.^2.))))))); %Force Transmissibility Equation
I have the following Error for this line of code:
Attached is the whole code:
%Clear WorkSpace
clc;
clear ;close all
%Define Variables
v=[0:0.1:100]; %Velocity Range
y = 0.35; %Y value
Amplitude = 0.35; %Amplitude in ft
Peroid = 12; %Peroid in ft
Weight = 155.42; %Mass in Slugs orignal 5000lbf
c = 40; %c in Lbs-s/ft
k = 165/12; %k in lb/ft
Wn = sqrt(k/Weight); %Model Variable
W = (((2*pi)/12).*v); %Model Variable
r = W/Wn; %Model Variable
zeta = (c/(2*(sqrt(Weight*k)))); %Model Variable
zetasq = zeta^2; %Model Variable Reduced
%Solve Equation
X = y*(sqrt(((4*zetasq*(r.^2.)+1))./(((1-(r.^2).^2)+(4*zetasq*(r.^2.)))))); % Displacement Transmissibilty Equation
%Plot Equation
figure(1)
plot(v,X)
%Make Look Pretty
grid on;
xlabel('velocity (Mph)');
ylabel('amplitude of X (ft)');
title('Amplitude of X vs velocity');
%Prep Second Plot
figure(2)
kk=1;
for v=[0.1:0.1:100] % velocity Range
%Solve Second Equation (Increments of 1)
Ft.(kk)= log((k.*y.*r.^2).*(sqrt(((4*zetasq*(r.^2.)+1))./(((1-(r.^2).^2)+(4*zetasq*(r.^2.))))))); %Force Transmissibility Equation
kk=kk+1;
end
v=[0.1:0.1:100]; %Velocity Range
plot(v,Ft)
%Make look Pretty
grid on;
xlabel('velocity (Mph)');
ylabel('amplitude of Ft(lb), log scale');
title('Amplitude of transmitted force Ft vs velocity');

采纳的回答

Steven Lord
Steven Lord 2021-5-5
The number 1 is not a valid struct array field name.
S = struct('a', 1, 'b', 2)
S = struct with fields:
a: 1 b: 2
S.('c') = 42 % works
S = struct with fields:
a: 1 b: 2 c: 42
S.(1) = -99 % does not work
Argument to dynamic structure reference must evaluate to a valid field name.
Immediately before this section of your code:
%Solve Second Equation (Increments of 1)
Ft.(kk)=
you define kk to be 1. You probably just want to get rid of the . there, use Ft(kk) = instead.
  2 个评论
Iplaysailing
Iplaysailing 2021-5-5
now i receive this error
Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
Error in VibrationsFinal (line 48)
Ft(kk)= log((k.*y.*r.^2).*(sqrt(((4*zetasq.*(r.^2.)+1))./(((1-(r.^2).^2)+(4*zetasq.*(r.^2.))))))); %#ok<SAGROW> %Force Transmissibility Equation
Steven Lord
Steven Lord 2021-5-5
Okay, so you're trying to store multiple elements from the right hand side into one element on the left hand side. That wouldn't work if you were trying to put multiple eggs in one cup of an egg carton (without scrambling) and it won't work here.
So you need to use a cell array or write your code so it writes to a block of elements on the left hand side that is the same size as the block of elements returned by the right hand side. For the former search the documentation for "cell array" and for the latter don't just use kk alone, write up an index expression that's big enough to hold what's on the right.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Assembly 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by