MATLAB For Loop Help: Plot SVAJ Accel Graph w/ Norton 5th Ed

  • Context: MATLAB 
  • Thread starter Thread starter Chandlerw88
  • Start date Start date
  • Tags Tags
    Loop Matlab
Click For Summary
SUMMARY

The forum discussion focuses on a MATLAB script designed to plot the acceleration graph of the SVAJ diagram from Robert Norton's "Design of Machinery" (5th edition). The user encounters an error related to the use of cell arrays, specifically the "Undefined operator '^' for input arguments of type 'cell'." The solution involves replacing cell arrays with standard arrays for variables 'b' and 'd'. This adjustment resolves the error and allows for successful execution of the plotting function.

PREREQUISITES
  • Familiarity with MATLAB programming and syntax
  • Understanding of cell arrays versus standard arrays in MATLAB
  • Basic knowledge of plotting functions in MATLAB
  • Concepts of acceleration and SVAJ diagrams in mechanical engineering
NEXT STEPS
  • Learn about MATLAB array manipulation and conversion between cell arrays and standard arrays
  • Explore MATLAB plotting functions and customization options
  • Study the SVAJ diagram and its applications in mechanical design
  • Review the relevant sections of "Design of Machinery" by Robert Norton for deeper insights
USEFUL FOR

Mechanical engineers, MATLAB users, and students studying dynamics or mechanical design who need assistance with plotting and data representation in MATLAB.

Chandlerw88
Messages
1
Reaction score
0
I have created a code in MATLAB that can plot the acceleration graph of the SVAJ diagram for 3 of the SCCA Family of Functions with a theta range from 0 to Beta. I cannot for the life of me, figure out what I am doing wrong, maybe some fresh eyes can help me. Ignore the 'trial', I'm trying to work for home, and didn't want to buy matlab. If you have the book Design of Machinery by Robert Norton 5th edition, its the figure on pg. 426. Thanks in advance to anyone that can help me
My script reads:
Code:
Trial>> b={.25, .25, .5}
b =
  1×3 cell array
    [0.2500]    [0.2500]    [0.5000]
Trial>> d={.25, .75, .5}
d =
  1×3 cell array
    [0.2500]    [0.7500]    [0.5000]
Trial>> for n=1:1:3
p=b(n)
z=d(n)
%Step 2: Create acceleration constant
Ca = 4*pi^2/((pi^2-8)*(p^2-z^2)-2*pi*(pi-2)*p+pi^2);
%zone 1 info%
x1 = 0:0.01:(p/2);
y1 = Ca*sin(pi*x1/p);
%zone 2 info%
x2 = p/2:0.01:(1-z)/2;
y2 = Ca;
%zone 3 info%
x3 = (1-z)/2:0.01:(1+z)/2;
y3 = Ca*cos(pi*(x3-(1-z)/2)/z);
%zone 4 info*
x4 = (1+z)/2 :0.01:1-p/2;
y4 = -Ca;
%zone 5 info%
x5 = (1-p/2):0.01:1;
y5 = Ca*sin(pi*(x5-1)/p);

x = [x1 x2 x3 x4 x5];
y = [y1 y2 y3 y4 y5];

plot(x,y)
end
p =
  cell
    [0.2500]

z =
  cell
    [0.2500]
Undefined operator '^' for input arguments of type 'cell'.   <---- this this the last error I received
 
Physics news on Phys.org
I don't understand why you are using cell arrays. You should be simply using arrays: b=[.25 .25 .5] and so on.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 2 ·
Replies
2
Views
4K
Replies
1
Views
3K
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 14 ·
Replies
14
Views
4K