LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How can I run "filename.m" using MATLAB ? (https://www.linuxquestions.org/questions/linux-software-2/how-can-i-run-filename-m-using-matlab-4175514941/)

Redsfan86 08-15-2014 06:30 AM

How can I run "filename.m" using MATLAB ?
 
Hi guys
I installed Matlab "for student version"
it works , as well as my results are ready for figures ....
I have no idea about MATLAP before
how could I run "filename.m" from MATLAP editor ?
what are the commands ...
Important note:I'm using Ubuntu 12.04 (32 bit) , the simulator is
LTE-Sim, the author of the scenario that I'm working on, made the graphic files use MATLAB
Cheers.
Regards

John VV 08-15-2014 10:12 PM

I use "octave" and not matlab

Octave is a gpl'ed clone of matlab
and is in the ubuntu repos , well every major OS's repos

as to the commands???????
without knowing WHAT the program dose and the variables in it .
there is NO way i can tell
Code:

matlab
filename.m

"filename.m" will likely have some arguments


normally one reads the instructions for the program
and / or
" read the code"
as in read the *.m file
What dose it do ?
what are the arguments?
and so on ....

Redsfan86 08-16-2014 02:42 AM

thanks a lot
First : I tried to use Octave, but I got errors + the author of the file himself advised me to use MATLAB.
as well as I'm not sure about the codes of octave that I'm used ....
so the first question ...
1- Could you please tell me in details how to execute "anyfilename.m"
Now .. what does the file works ....
First of all , there are many files (.m) I have, not only this one
these files are responsible to generate simulation results figures for scheduling algorithms....
Here are the Full codes (makegrahs.m): this is the file that we have to run ...
Code:

clc;
close all;
clear all;

sched=[1 6 5 4]; % PF; LOG; EXP; FLS
users=[10 20 30 40];
delay=[0.04 0.06 0.08 0.1];
speed=[3 120];


test='PLRVIDEO';
for v=1:length(speed)
for ue=1:length(users)
    for d=1:length(delay)
    for s=1:length(sched)
        dat=load(strcat('OUT/',test,'_SCHED_',num2str(sched(s)),'_UE_',num2str(users(ue)), '_V_',num2str(speed(v)),'_D_',num2str(delay(d))));
        mat(s,d)=mean(dat);
    end
    end
    t=strcat(test,'_SPEED_',num2str(speed(v)),'_UEs_',num2str(users(ue)));
    y='PLR [%]';
    ymax=100;
    ymin=0;
    plotnormal(mat',t, y, ymin, ymax)
end
end

test='TPUTVIDEO';
for v=1:length(speed)
for ue=1:length(users)
    for d=1:length(delay)
    for s=1:length(sched)
        dat=load(strcat('OUT/',test,'_SCHED_',num2str(sched(s)),'_UE_',num2str(users(ue)), '_V_',num2str(speed(v)),'_D_',num2str(delay(d))));
        mat(s,d)=mean(dat);
    end
    end
    t=strcat(test,'_SPEED_',num2str(speed(v)),'_UEs_',num2str(users(ue)));
    y='Goodput [Mbps]';
    ymax=5;
    mat=mat./1000000;
    ymin=0;
    plotnormal(mat',t, y, ymin, ymax)
end
end


test='DELVIDEO';
for v=1:length(speed)
for ue=1:length(users)
    for d=1:length(delay)
    for s=1:length(sched)
        dat=load(strcat('OUT/',test,'_SCHED_',num2str(sched(s)),'_UE_',num2str(users(ue)), '_V_',num2str(speed(v)),'_D_',num2str(delay(d))));
        mat(s,d)=mean(dat);
    end
    end
    t=strcat(test,'_SPEED_',num2str(speed(v)),'_UEs_',num2str(users(ue)));
    y='Goodput [Mbps]';
    y='Packets Delay [s]';
    ymax=100;
    ymin=0.01;
    plotlog(mat',t, y, ymin, ymax)
end
end







test='PLRVOIP';
for v=1:length(speed)
for ue=1:length(users)
    for d=1:length(delay)
    for s=1:length(sched)
        dat=load(strcat('OUT/',test,'_SCHED_',num2str(sched(s)),'_UE_',num2str(users(ue)), '_V_',num2str(speed(v)),'_D_',num2str(delay(d))));
        mat(s,d)=mean(dat);
    end
    end
    t=strcat(test,'_SPEED_',num2str(speed(v)),'_UEs_',num2str(users(ue)));
    y='PLR [%]';
    ymax=20;
    ymin=0;
    plotnormal(mat',t, y, ymin, ymax)
end
end

test='TPUTVOIP';
for v=1:length(speed)
for ue=1:length(users)
    for d=1:length(delay)
    for s=1:length(sched)
        dat=load(strcat('OUT/',test,'_SCHED_',num2str(sched(s)),'_UE_',num2str(users(ue)), '_V_',num2str(speed(v)),'_D_',num2str(delay(d))));
        mat(s,d)=mean(dat);
    end
    end
    t=strcat(test,'_SPEED_',num2str(speed(v)),'_UEs_',num2str(users(ue)));
    y='Goodput [Mbps]';
    ymax=1;
    mat=mat./1000000;
    ymin=0;
    plotnormal(mat',t, y, ymin, ymax)
end
end


test='DELVOIP';
for v=1:length(speed)
for ue=1:length(users)
    for d=1:length(delay)
    for s=1:length(sched)
        dat=load(strcat('OUT/',test,'_SCHED_',num2str(sched(s)),'_UE_',num2str(users(ue)), '_V_',num2str(speed(v)),'_D_',num2str(delay(d))));
        mat(s,d)=mean(dat);
    end
    end
    t=strcat(test,'_SPEED_',num2str(speed(v)),'_UEs_',num2str(users(ue)));
    y='Goodput [Mbps]';
    y='Packets Delay [s]';
    ymax=1;
    ymin=0.001;
    plotlog(mat',t, y, ymin, ymax)
end
end











test='TPUTBE';
for v=1:length(speed)
for ue=1:length(users)
    for d=1:length(delay)
    for s=1:length(sched)
        dat=load(strcat('OUT/',test,'_SCHED_',num2str(sched(s)),'_UE_',num2str(users(ue)), '_V_',num2str(speed(v)),'_D_',num2str(delay(d))));
        mat(s,d)=mean(dat);
    end
    end
    t=strcat(test,'_SPEED_',num2str(speed(v)),'_UEs_',num2str(users(ue)));
    y='Goodput [Mbps]';
    ymax=10;
    mat=mat./1000000;
    ymin=0;
    plotnormal(mat',t, y, ymin, ymax)
end
end

This is the code for createfigure.m
Code:

function createfigure(ymatrix1, t, y, ymax)


figure1 = figure('Name', t);

axes1 = axes('Parent',figure1,'XTickLabel',{'10','20','30'},'XTick',[1 2 3],'FontSize',20);
box(axes1,'on');
grid(axes1,'on');
hold(axes1,'all');

% Create multiple lines using matrix input to bar
bar1 = bar(ymatrix1,'Parent',axes1);
set(bar1(1),'DisplayName','PF');
set(bar1(2),'DisplayName','FLS');
set(bar1(3),'DisplayName','EXP');
set(bar1(4),'DisplayName','LOG');

xlabel('Number of Users','FontSize',20);
ylabel(y,'FontSize',20);
ylim ([0 ymax]);

legend1 = legend(axes1,'show');
set(legend1,...
    'Position',[0.794558608718962 0.753098188751188 0.0997122246143713 0.157112868804529]);

saveas(figure1, t, 'png')

plotlog.m full code
Code:

function plotlog(ymatrix1, t, y, ymin, ymax)
%CREATEFIGURE1(YMATRIX1)
%  YMATRIX1:  bar matrix data

%  Auto-generated by MATLAB on 05-Mar-2013 21:48:14

% Create figure
figure1 = figure('Name', t);

% Create axes
axes1 = axes('Parent',figure1,'YScale','log','YMinorTick','on',...
    'YMinorGrid','on',...
    'XTickLabel',{'0.04','0.06','0.08','0.1'},...
    'XTick',[1 2 3 4],...
    'FontSize',20);
% Uncomment the following line to preserve the Y-limits of the axes
% ylim(axes1,[0.1 100]);
box(axes1,'on');
grid(axes1,'on');
hold(axes1,'all');

% Create multiple lines using matrix input to bar
bar1 = bar(ymatrix1,'BaseValue',ymin,'Parent',axes1);
set(bar1(1),'DisplayName','Proportional Fair');
set(bar1(2),'DisplayName','LOG rule');
set(bar1(3),'DisplayName','EXP rule');
set(bar1(4),'DisplayName','Frame Level Scheduler');

% Create xlabel
xlabel('Target Delay [s]','FontSize',20);

% Create ylabel
ylabel(y,'FontSize',20);

ylim ([ymin ymax])

% Create legend
legend1 = legend(axes1,'show');
set(legend1,'Location','NorthOutside');
saveas(figure1, t, 'png')

Full code for plotnormal.m
Code:

function plotnormal(ymatrix1, t, y, ymin, ymax)
%CREATEFIGURE1(YMATRIX1)
%  YMATRIX1:  bar matrix data

%  Auto-generated by MATLAB on 05-Mar-2013 21:48:14

% Create figure
figure1 = figure('Name', t);

% Create axes
axes1 = axes('Parent',figure1,'YMinorTick','on',...
    'YMinorGrid','on',...
    'XTickLabel',{'0.04','0.06','0.08','0.1'},...
    'XTick',[1 2 3 4],...
    'FontSize',20);
% Uncomment the following line to preserve the Y-limits of the axes
% ylim(axes1,[0.1 100]);
box(axes1,'on');
grid(axes1,'on');
hold(axes1,'all');

% Create multiple lines using matrix input to bar
bar1 = bar(ymatrix1,'BaseValue',ymin,'Parent',axes1);
set(bar1(1),'DisplayName','Proportional Fair');
set(bar1(2),'DisplayName','LOG rule');
set(bar1(3),'DisplayName','EXP rule');
set(bar1(4),'DisplayName','Frame Level Scheduler');

% Create xlabel
xlabel('Target Delay [s]','FontSize',20);

% Create ylabel
ylabel(y,'FontSize',20);

ylim ([ymin ymax])

% Create legend
legend1 = legend(axes1,'show');
set(legend1,'Location','NorthOutside');
saveas(figure1, t, 'png')

These are the files for the graphic ....
according to the author:
Code:

- run simulations:
        sh run.sh

- elaborate simulations' output
        sh postsim.sh

- generate graphs using the makegraphs.m file (using Matlab)

I've done the first two steps , still the figures for me ....
I'v installed octave .... but I got some errors ....
So could you please help me in any way (MATLAB0 or Octave) ..
I don't care , I care about the figures....
thanks a lot
Regards.

Redsfan86 08-16-2014 05:28 AM

Here I will summarize all my efforts to make this codes working for me using octave
I installed octave using
Code:

sudo get-apt update
sudo get-apt install octave

here I started to try so many times , using different commands ...
I used:
Code:

./makegraphs
I used:
Code:

sudo octave makegraphs.m
I usded:
Code:

octave makegraphs.m
these commands I get from wikis to use..... all of theses commands
didn't work for me, I got different errors depending on the command that I'v used....
the last cammand I used , it was like this:
Code:

cat makegraphs.m
then
Code:

makegraphs
Code:

octave:1> makegraphs
I get a figure this time without any line, only I get x,y
here is the link that I used the previous commands to generate the figures
http://octave.1599824.n4.nabble.com/...td1628403.html
Cheers

John VV 08-17-2014 07:31 PM

I take it that "LTE-Sim" is installed and worksand is outputing data

the data that the matlab files use


All times are GMT -5. The time now is 02:29 PM.