How to add zero at the very beginning of my column matrix?
53 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Robert Flores
le 18 Avr 2019
Modifié(e) : Adam Danz
le 18 Avr 2019
Hello everyone,
I am plotting a stress-strain curve and would like to insert a point at the origin. I have tried using the zeros function but have not found any luck yet. I keep getting an error stating that the "dimensions of arrays being concatenated are not consistent". If you can please help me resolve this issue, it'll be greatly appreciated, thanks in advance.
CODE:
%% Stress & Strain Curve from Force Actuator
exist('DIC_test.08.02.xlsx','file');
Data = importdata('DIC_test.08.02.xlsx');
Time = Data(:,1); Force = Data(:,2); Displacement = Data(:,3);
Area = (6.26e-3)*(1.57e-3); Lo = 27.07;
Eng_Stress = Force/Area;
Eng_Stress(Eng_Stress < 0) = NaN;
Eng_Stress = Eng_Stress(327:end);
Eng_Stress = [zeros(1), Eng_Stress]; % This is the column I am trying to add a zero at the very beginning
Eng_Strain = (Displacement)/Lo;
Eng_Strain = Eng_Strain - Eng_Strain(327);
Eng_Strain = Eng_Strain(327:end);
Eng_Strain = zeros(1) + Eng_Strain; % This one I think is okay
Percent_Elongation = (Displacement(end)/Lo)*100;
E_FA = ((Eng_Stress(600)-Eng_Stress(500))/(Eng_Strain(600)-Eng_Strain(500)))/(1e9)
figure(1)
plot(Eng_Strain,Eng_Stress,'r')
ytickformat('%12.2f')
ax = gca;
ax.YAxis.Exponent = 6;
hold on
plot(Eng_Strain(500),Eng_Stress(500),'b *')
plot(Eng_Strain(600),Eng_Stress(600),'b *')
grid on
title('Stress v. Strain Force Actuator'); xlabel('Strain Measured in mm/mm'); ylabel('Stress measured in Pa')
0 commentaires
Réponse acceptée
Adam Danz
le 18 Avr 2019
Modifié(e) : Adam Danz
le 18 Avr 2019
Use a semicolon instead of a comma. The variable 'Eng_Strain' is a column vector so you need to vertically concatenate the zero with the vector.
Eng_Stress = [zeros(1); Eng_Stress];
% ^
Or just
Eng_Stress = [0; Eng_Stress];
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Stress and Strain dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!