Saving data from for loops

Hello!
I am trying to plot all the Y-values from the for loop but it seems that I recieve a new Y-value from every itterations. I think that when plotting, I only plot ONE Y-value. not all of them. I believe saving all the Y-values into a array would make it possible to plot X,Y. How can I save the Y-values? Or is there any other way to plot my data?
clear all
close all
clc
Mmax=10.76; %Maximum mass
Mmin=10.32; %Minimum mass
Mdiff=0.44; %Mass difference
UptakeW=(Mdiff/Mmin); %In percentage
A=load('MMC#8-PURE_TGA-Heated_Samples_05102020.txt');
B=A(2735:4823,5);
X=0:0.1:50;
for i=0:0.01:Mdiff
Y=((i)./Mdiff)*100
end
plot(X,Y)

 采纳的回答

KSSV
KSSV 2020-10-6
编辑:KSSV 2020-10-6
clear all
close all
clc
Mmax=10.76; %Maximum mass
Mmin=10.32; %Minimum mass
Mdiff=0.44; %Mass difference
UptakeW=(Mdiff/Mmin); %In percentage
A=load('MMC#8-PURE_TGA-Heated_Samples_05102020.txt');
B=A(2735:4823,5);
X=0:0.1:50;
XX = 0:0.01:Mdiff ;
Y = zeros(size(XX)) ;
for i=1:length(XX) ;
Y(i)=(XX(i)./Mdiff)*100
end
plot(XX,Y)
No loop required actually:
clear all
close all
clc
Mmax=10.76; %Maximum mass
Mmin=10.32; %Minimum mass
Mdiff=0.44; %Mass difference
UptakeW=(Mdiff/Mmin); %In percentage
A=load('MMC#8-PURE_TGA-Heated_Samples_05102020.txt');
B=A(2735:4823,5);
X=0:0.1:50;
XX = 0:0.01:Mdiff ;
Y = XX/Mdiff*100 ;
plot(XX,Y)

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Agriculture 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by