How to add zero at the very beginning of my column matrix?

조회 수: 66 (최근 30일)
Robert  Flores
Robert Flores 2019년 4월 18일
편집: Adam Danz 2019년 4월 18일
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')

채택된 답변

Adam Danz
Adam Danz 2019년 4월 18일
편집: Adam Danz 2019년 4월 18일
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개)

카테고리

Help CenterFile Exchange에서 Stress and Strain에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by