Error with plot command
Show older comments
I am just trying to do a basic plot but I can't seem to get it to work. I keep getting an error saying
"Index exceeds the number of array elements. Index must not exceed 1"
My code for the plot is below
clear all
clc
fre = 10e6; % Frequency in Hz
wave_type = 1; % wave_type Longitudinal == 1; Shear == 2
atten_type = 1; % atten_type Distribution == 1; Single Grain Size == 2; Rayleigh Approx. == 3
L = 15; % distribution mean in um
sigma_d = 0.5; % distribution width (PDF in https://en.wikipedia.org/wiki/Log-normal_distribution)
% % Titanium
C11 = 160E9; C12 = 90E9; C13 = 66E9; C33 = 181E9; C44 = 46.5E9; % Single crystal elastic constants
[c11, c12, c13, c14, c15, c16, c22, c23, c24, c25, c26, c33, c34, c35, c36, c44, c45, c46, c55, c56, c66] = deal(C11,C12,C13,0,0,0,C11,C13,0,0,0,C33,0,0,0,C44,0,0,C44,0,(1/2)*(C11-C12));
density = 4506;
velocity= 6100;
for fre = 1:10
atten_coff(1,fre) = atten_func_dist(fre,wave_type,atten_type,L,sigma_d,density,c11, c12, c13, c14, c15, c16, c22, c23, c24, c25, c26, c33, c34, c35, c36, c44, c45, c46, c55, c56, c66);
end
loglog(fre(1:10), atten_coff)
Thanks
Dave
1 Comment
Kevin Holly
on 16 Jan 2023
What is atten_func_dist?
Accepted Answer
More Answers (1)
I do not think this is a problem of plot, but rather that your variable has only 1 value and you are addressing a higher value. E.g.
V=[ 1 2 3];
V(4)
Categories
Find more on Inverse Gaussian Distribution 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!