Does Any one know what am I doing here and what is the solution for it?
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I am basically plotting 10 curves on the graph and on each curves I would like to put some text. In my mind, I am doing the write thing but still getting error. Can anyone point me in the right direction:
Errors:
Error: File: asad1.m Line: 26 Column: 12
Indexing with parentheses '()' must appear as the last operation of a valid indexing expression.
Code:
close all
clear all
clc
w = [0,0.00106230528000000,0.00424922112000000,0.00956074752000000,0.0169968844800000,0.0265576320000000,0.0382429900800000,0.0520529587200000,0.0679875379200000,0.0860467276800000,0.106230528000000,0.128538938880000,0.152971960320000,0.179529592320000,0.208211834880000,0.239018688000000,0.271950151680000,0.307006225920000,0.344186910720000,0.383492206080000,0.424922112000000,0.468476628480000,0.514155755520000,0.561959493120000,0.611887841280000,0.663940800000000,0.718118369280000,0.774420549120000,0.832847339520000,0.893398740480000,0.956074752000000,1.02087537408000,1.08780060672000,1.15685044992000,1.22802490368000,1.30132396800000,1.37674764288000,1.45429592832000,1.53396882432000,1.61576633088000,1.69968844800000,1.78573517568000,1.87390651392000,1.96420246272000,2.05662302208000,2.15116819200000,2.24783797248000,2.34663236352000,2.44755136512000,2.55059497728000,2.65576320000000,2.76305603328000,2.87247347712000,2.98401553152000,3.09768219648000,3.21347347200000,3.33138935808000,3.45142985472000,3.57359496192000,3.69788467968000,3.82429900800000,3.95283794688000,4.08350149632000,4.21628965632000,4.35120242688000,4.48823980800000,4.62740179968000,4.76868840192000,4.91209961472000,5.05763543808000,5.20529587200000,5.35508091648000,5.50699057152000,5.66102483712000,5.81718371328000,5.97546720000000].';
%w = 0.00106230528000000
x = [0:0.008:3.4];
L = 3.4;
E = 2.1E11;
I = ((0.008)^4)/12;
y = (((w.*x).*(L-x))/(24*E*I*L)).*(L^2+(x.*(L-x)));
% y(10:10:end, :)
% or some y's like this:
% plot(x, y([1, 5, 10, 40, 50, 55],:))
% that plots only some curves
plot (x,y(1:10:end,:),'Color',[0.4940, 0.1840, 0.5560],'LineStyle','-','LineWidth',1.5);
hold on
i = round(numel(x)/2);
% Get the local slope
d = (y(i+1)-y(i))/(x(i+1)-x(i));
X = diff(get(gca, 'xlim'));
Y = diff(get(gca, 'ylim'));
p = pbaspect;
a = (d*p(2)*X/p(1)/Y)*90/pi;
% Display the text
text(x(i), y(i)(1:10:end,:), 'Width=0.7m','FontSize',8,'BackgroundColor', 'w', 'rotation', a); %Error line
%text(x(i), y(i), 'Width=0.7m','FontSize',8,'BackgroundColor', 'w', 'rotation', a); %It is working with this line but only show one label on the curve
hold on
0 个评论
采纳的回答
Ameer Hamza
2020-10-19
This y(i)(1:10:end,:) is not a valid MATLAB syntax. Just use y(i)
text(x(i), y(i), 'Width=0.7m', ...
2 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Entering Commands 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!