Equation Error Argument to dynamic structure reference must evaluate to a valid field name
3 views (last 30 days)
Show older comments
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');
0 Comments
Accepted Answer
Steven Lord
on 5 May 2021
The number 1 is not a valid struct array field name.
S = struct('a', 1, 'b', 2)
S.('c') = 42 % works
S.(1) = -99 % does not work
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 Comments
Steven Lord
on 5 May 2021
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.
More Answers (0)
See Also
Categories
Find more on Assembly in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!