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)

 Accepted Answer

KSSV
KSSV on 6 Oct 2020
Edited: KSSV on 6 Oct 2020
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)

More Answers (0)

Categories

Find more on Agriculture 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!