Tag Archives: matlab
Error in loading the bit file to Hardware
Hello everyone,
I am using SOC blockset support package for my project in that i have to upload the bit file to my hardware which is generated through Build, Configure and deploy procedure.
While building the model i am experiencing an error of
Error Report: Command "matlabshared.toolchain.gcc_linaro.internal.addCompilerPath(‘6.3.1′,’AARCH64’);" threw an error: The path ‘C:ProgramDataMATLABSupportPackagesR2022b3P.instrsetlinarogcctoolchain_6_3.instrsetbin’ does not exist.
And the build summary I have attached below.
### RF Data Converter configuration script written to:
E:Wigig_SigGenIQNew_modelIQ22A_32Dsoc_prjpstopl_top_rfdc_setup.m
### Using the SoC system information from ‘E:Wigig_SigGenIQNew_modelIQ22A_32Dsoc_prjsocsysinfo.mat’
### Generating software system pstopl_top_sw
### Generated software system : E:Wigig_SigGenIQNew_modelIQ22A_32Dsoc_prjpstopl_top_sw.slx.
### Starting serial model reference code generation build.
### Checking status of model reference code generation target for model ‘pstopl_proc’ used in ‘pstopl_top_sw’.
### Checking for structural changes in pstopl_proc because the model reference rebuild option is set to ‘If any changes detected’. Structural changes cause the model reference code generation target to be rebuilt.
### Starting build procedure for: pstopl_proc
### Generating code and artifacts to ‘Model specific’ folder structure
### Code for the model reference code generation target for model pstopl_proc is up to date because no functional changes were found in referenced model.
### Model reference code generation target for pstopl_proc is up to date.
### Starting build procedure for: pstopl_top_sw
### Generating code and artifacts to ‘Model specific’ folder structure
### Generating code into build folder: E:Wigig_SigGenIQNew_modelIQ22A_32Dpstopl_top_sw_ert_rtw
### Invoking Target Language Compiler on pstopl_top_sw.rtw
### Using System Target File: C:Program FilesMATLABR2022brtwcertert.tlc
### Loading TLC function libraries
…….
### Initial pass through model to cache user defined code
..
### Caching model source code
………………………….
### Writing header file pstopl_top_sw_types.h
### Writing header file pstopl_top_sw.h
### Writing source file pstopl_top_sw.c
### Writing header file pstopl_top_sw_private.h
.
### Writing header file E:Wigig_SigGenIQNew_modelIQ22A_32Dslprjert_sharedutilsudpRxTask_trigger.h
### Writing header file rtmodel.h
### Writing source file ert_main.c
### TLC code generation complete (took 6.181s).
.### Saving binary information cache.
### Using toolchain: Linaro AArch64 Linux v6.3.1
### Creating ‘E:Wigig_SigGenIQNew_modelIQ22A_32Dpstopl_top_sw_ert_rtwpstopl_top_sw.mk’ …
### Building ‘pstopl_top_sw’: "C:PROGRA~1MATLABR2022bbinwin64gmake" -f pstopl_top_sw.mk all
### Build procedure for pstopl_top_sw aborted due to an error.
Build Summary
Top model targets built:
Model Action Rebuild Reason
================================================================================
pstopl_top_sw Failed Build artifacts are incompatible with current location.
0 of 2 models built (1 models already up to date)
Build duration: 0h 0m 40.431s
I am using ZCU111 evaluation kit. I was working fine till last week and when i am taking this project after a week this error shows up. How to solve this error.Hello everyone,
I am using SOC blockset support package for my project in that i have to upload the bit file to my hardware which is generated through Build, Configure and deploy procedure.
While building the model i am experiencing an error of
Error Report: Command "matlabshared.toolchain.gcc_linaro.internal.addCompilerPath(‘6.3.1′,’AARCH64’);" threw an error: The path ‘C:ProgramDataMATLABSupportPackagesR2022b3P.instrsetlinarogcctoolchain_6_3.instrsetbin’ does not exist.
And the build summary I have attached below.
### RF Data Converter configuration script written to:
E:Wigig_SigGenIQNew_modelIQ22A_32Dsoc_prjpstopl_top_rfdc_setup.m
### Using the SoC system information from ‘E:Wigig_SigGenIQNew_modelIQ22A_32Dsoc_prjsocsysinfo.mat’
### Generating software system pstopl_top_sw
### Generated software system : E:Wigig_SigGenIQNew_modelIQ22A_32Dsoc_prjpstopl_top_sw.slx.
### Starting serial model reference code generation build.
### Checking status of model reference code generation target for model ‘pstopl_proc’ used in ‘pstopl_top_sw’.
### Checking for structural changes in pstopl_proc because the model reference rebuild option is set to ‘If any changes detected’. Structural changes cause the model reference code generation target to be rebuilt.
### Starting build procedure for: pstopl_proc
### Generating code and artifacts to ‘Model specific’ folder structure
### Code for the model reference code generation target for model pstopl_proc is up to date because no functional changes were found in referenced model.
### Model reference code generation target for pstopl_proc is up to date.
### Starting build procedure for: pstopl_top_sw
### Generating code and artifacts to ‘Model specific’ folder structure
### Generating code into build folder: E:Wigig_SigGenIQNew_modelIQ22A_32Dpstopl_top_sw_ert_rtw
### Invoking Target Language Compiler on pstopl_top_sw.rtw
### Using System Target File: C:Program FilesMATLABR2022brtwcertert.tlc
### Loading TLC function libraries
…….
### Initial pass through model to cache user defined code
..
### Caching model source code
………………………….
### Writing header file pstopl_top_sw_types.h
### Writing header file pstopl_top_sw.h
### Writing source file pstopl_top_sw.c
### Writing header file pstopl_top_sw_private.h
.
### Writing header file E:Wigig_SigGenIQNew_modelIQ22A_32Dslprjert_sharedutilsudpRxTask_trigger.h
### Writing header file rtmodel.h
### Writing source file ert_main.c
### TLC code generation complete (took 6.181s).
.### Saving binary information cache.
### Using toolchain: Linaro AArch64 Linux v6.3.1
### Creating ‘E:Wigig_SigGenIQNew_modelIQ22A_32Dpstopl_top_sw_ert_rtwpstopl_top_sw.mk’ …
### Building ‘pstopl_top_sw’: "C:PROGRA~1MATLABR2022bbinwin64gmake" -f pstopl_top_sw.mk all
### Build procedure for pstopl_top_sw aborted due to an error.
Build Summary
Top model targets built:
Model Action Rebuild Reason
================================================================================
pstopl_top_sw Failed Build artifacts are incompatible with current location.
0 of 2 models built (1 models already up to date)
Build duration: 0h 0m 40.431s
I am using ZCU111 evaluation kit. I was working fine till last week and when i am taking this project after a week this error shows up. How to solve this error. Hello everyone,
I am using SOC blockset support package for my project in that i have to upload the bit file to my hardware which is generated through Build, Configure and deploy procedure.
While building the model i am experiencing an error of
Error Report: Command "matlabshared.toolchain.gcc_linaro.internal.addCompilerPath(‘6.3.1′,’AARCH64’);" threw an error: The path ‘C:ProgramDataMATLABSupportPackagesR2022b3P.instrsetlinarogcctoolchain_6_3.instrsetbin’ does not exist.
And the build summary I have attached below.
### RF Data Converter configuration script written to:
E:Wigig_SigGenIQNew_modelIQ22A_32Dsoc_prjpstopl_top_rfdc_setup.m
### Using the SoC system information from ‘E:Wigig_SigGenIQNew_modelIQ22A_32Dsoc_prjsocsysinfo.mat’
### Generating software system pstopl_top_sw
### Generated software system : E:Wigig_SigGenIQNew_modelIQ22A_32Dsoc_prjpstopl_top_sw.slx.
### Starting serial model reference code generation build.
### Checking status of model reference code generation target for model ‘pstopl_proc’ used in ‘pstopl_top_sw’.
### Checking for structural changes in pstopl_proc because the model reference rebuild option is set to ‘If any changes detected’. Structural changes cause the model reference code generation target to be rebuilt.
### Starting build procedure for: pstopl_proc
### Generating code and artifacts to ‘Model specific’ folder structure
### Code for the model reference code generation target for model pstopl_proc is up to date because no functional changes were found in referenced model.
### Model reference code generation target for pstopl_proc is up to date.
### Starting build procedure for: pstopl_top_sw
### Generating code and artifacts to ‘Model specific’ folder structure
### Generating code into build folder: E:Wigig_SigGenIQNew_modelIQ22A_32Dpstopl_top_sw_ert_rtw
### Invoking Target Language Compiler on pstopl_top_sw.rtw
### Using System Target File: C:Program FilesMATLABR2022brtwcertert.tlc
### Loading TLC function libraries
…….
### Initial pass through model to cache user defined code
..
### Caching model source code
………………………….
### Writing header file pstopl_top_sw_types.h
### Writing header file pstopl_top_sw.h
### Writing source file pstopl_top_sw.c
### Writing header file pstopl_top_sw_private.h
.
### Writing header file E:Wigig_SigGenIQNew_modelIQ22A_32Dslprjert_sharedutilsudpRxTask_trigger.h
### Writing header file rtmodel.h
### Writing source file ert_main.c
### TLC code generation complete (took 6.181s).
.### Saving binary information cache.
### Using toolchain: Linaro AArch64 Linux v6.3.1
### Creating ‘E:Wigig_SigGenIQNew_modelIQ22A_32Dpstopl_top_sw_ert_rtwpstopl_top_sw.mk’ …
### Building ‘pstopl_top_sw’: "C:PROGRA~1MATLABR2022bbinwin64gmake" -f pstopl_top_sw.mk all
### Build procedure for pstopl_top_sw aborted due to an error.
Build Summary
Top model targets built:
Model Action Rebuild Reason
================================================================================
pstopl_top_sw Failed Build artifacts are incompatible with current location.
0 of 2 models built (1 models already up to date)
Build duration: 0h 0m 40.431s
I am using ZCU111 evaluation kit. I was working fine till last week and when i am taking this project after a week this error shows up. How to solve this error. matlab, socblockset, simulink MATLAB Answers — New Questions
how to ds mapping
Hi, basically i’m trying to write a code to compare the values that i have on a table with a certain range and give it a value
if Accel >= 0.28 & Accel < 2.1 this is equal to number 1
if Accel >= 2.11 & Accel < 3.63 is equal to number 2
and then with both values use it to create a map.Hi, basically i’m trying to write a code to compare the values that i have on a table with a certain range and give it a value
if Accel >= 0.28 & Accel < 2.1 this is equal to number 1
if Accel >= 2.11 & Accel < 3.63 is equal to number 2
and then with both values use it to create a map. Hi, basically i’m trying to write a code to compare the values that i have on a table with a certain range and give it a value
if Accel >= 0.28 & Accel < 2.1 this is equal to number 1
if Accel >= 2.11 & Accel < 3.63 is equal to number 2
and then with both values use it to create a map. ds map MATLAB Answers — New Questions
Error popped : Failed Code generation information file does not exist. 0 of 1 models built (0 models already up to date)
While deploying a trial code on my STM32 F446ZE MCU following error popped up :-
### Starting build procedure for: TRIAL_2 ### Build procedure for TRIAL_2 aborted due to an error.
Build Summary
Top model targets built: Model Action Rebuild Reason =================================================================== TRIAL_2 Failed Code generation information file does not exist. 0 of 1 models built (0 models already up to date) Build duration: 0h 0m 1.169s
STM32 Project must be generated with NoMain option enabled.While deploying a trial code on my STM32 F446ZE MCU following error popped up :-
### Starting build procedure for: TRIAL_2 ### Build procedure for TRIAL_2 aborted due to an error.
Build Summary
Top model targets built: Model Action Rebuild Reason =================================================================== TRIAL_2 Failed Code generation information file does not exist. 0 of 1 models built (0 models already up to date) Build duration: 0h 0m 1.169s
STM32 Project must be generated with NoMain option enabled. While deploying a trial code on my STM32 F446ZE MCU following error popped up :-
### Starting build procedure for: TRIAL_2 ### Build procedure for TRIAL_2 aborted due to an error.
Build Summary
Top model targets built: Model Action Rebuild Reason =================================================================== TRIAL_2 Failed Code generation information file does not exist. 0 of 1 models built (0 models already up to date) Build duration: 0h 0m 1.169s
STM32 Project must be generated with NoMain option enabled. stm32, mcu, basic MATLAB Answers — New Questions
How to model a hf transformer for dc dc converter
Suppose a model is a dc dc converter with intermediate ac conversion means the system is dc-ac-dc. for that inverter we generally use switches with high frequency. now its output is connected to transformer for boosting. now the question is the output of inverter is of 100khz (supposed) & is fed to transformer. what is the frequency of transformer to be kept.
As of this a hf transformer is required. So how to model a hf transformer in simulink.
can anyone address this issue with step by step procedureSuppose a model is a dc dc converter with intermediate ac conversion means the system is dc-ac-dc. for that inverter we generally use switches with high frequency. now its output is connected to transformer for boosting. now the question is the output of inverter is of 100khz (supposed) & is fed to transformer. what is the frequency of transformer to be kept.
As of this a hf transformer is required. So how to model a hf transformer in simulink.
can anyone address this issue with step by step procedure Suppose a model is a dc dc converter with intermediate ac conversion means the system is dc-ac-dc. for that inverter we generally use switches with high frequency. now its output is connected to transformer for boosting. now the question is the output of inverter is of 100khz (supposed) & is fed to transformer. what is the frequency of transformer to be kept.
As of this a hf transformer is required. So how to model a hf transformer in simulink.
can anyone address this issue with step by step procedure hf transformer, dc dc converter MATLAB Answers — New Questions
Regarding Regression cofficient in ANN
Regression plot which we are getting in ANN showing value of R. How the R is calculated and what is the equation of it. what is the difference between correlation factor and this regression coefficient and coefficient of determination.Regression plot which we are getting in ANN showing value of R. How the R is calculated and what is the equation of it. what is the difference between correlation factor and this regression coefficient and coefficient of determination. Regression plot which we are getting in ANN showing value of R. How the R is calculated and what is the equation of it. what is the difference between correlation factor and this regression coefficient and coefficient of determination. ann MATLAB Answers — New Questions
Converging Errors in mathematical model of UAV launcher.
I have modelled a UAV launcher based on Alexander Khrulev’s paper "Analysis of Pneumatic UAV Launcher Parameters" 2023, which is an open-source paper available at ScienceDirect. I am getting different errors, but the most concerning is that my temperature drops to 0K during working, leading to errors as well as unrealistic behavior. The system consists of 4 differential equations which are tightly coupled, so I am having trouble locating exactly where the problem is. I suspect the problem is in gas dynamics modelling, especially in the intermediate "phi" and "leakage flow rate dm/dt" modelling in the pressure subsystem. I have attached the paper, my workspace as well as my Simulink model in case someone wants to have a look or guide me through this problem. I will be most thankful.I have modelled a UAV launcher based on Alexander Khrulev’s paper "Analysis of Pneumatic UAV Launcher Parameters" 2023, which is an open-source paper available at ScienceDirect. I am getting different errors, but the most concerning is that my temperature drops to 0K during working, leading to errors as well as unrealistic behavior. The system consists of 4 differential equations which are tightly coupled, so I am having trouble locating exactly where the problem is. I suspect the problem is in gas dynamics modelling, especially in the intermediate "phi" and "leakage flow rate dm/dt" modelling in the pressure subsystem. I have attached the paper, my workspace as well as my Simulink model in case someone wants to have a look or guide me through this problem. I will be most thankful. I have modelled a UAV launcher based on Alexander Khrulev’s paper "Analysis of Pneumatic UAV Launcher Parameters" 2023, which is an open-source paper available at ScienceDirect. I am getting different errors, but the most concerning is that my temperature drops to 0K during working, leading to errors as well as unrealistic behavior. The system consists of 4 differential equations which are tightly coupled, so I am having trouble locating exactly where the problem is. I suspect the problem is in gas dynamics modelling, especially in the intermediate "phi" and "leakage flow rate dm/dt" modelling in the pressure subsystem. I have attached the paper, my workspace as well as my Simulink model in case someone wants to have a look or guide me through this problem. I will be most thankful. simulink, matlab, mathematical modelling MATLAB Answers — New Questions
Error forming mini-batch of targets for network output “fc”. Data interpreted with format “BC”.
I worked on time series forecasting supportte dby Matlab. However, i first tried the sample provided by Matlab. But I got the error of Error forming mini-batch of targets for network output "fc", Data interpreted with format "BC" when I used training function — trainnet(XTrain, TTrain, net_1,"mse",options). I appreciate for any suggestion or comment.I worked on time series forecasting supportte dby Matlab. However, i first tried the sample provided by Matlab. But I got the error of Error forming mini-batch of targets for network output "fc", Data interpreted with format "BC" when I used training function — trainnet(XTrain, TTrain, net_1,"mse",options). I appreciate for any suggestion or comment. I worked on time series forecasting supportte dby Matlab. However, i first tried the sample provided by Matlab. But I got the error of Error forming mini-batch of targets for network output "fc", Data interpreted with format "BC" when I used training function — trainnet(XTrain, TTrain, net_1,"mse",options). I appreciate for any suggestion or comment. dd-tsf-251 MATLAB Answers — New Questions
MIMO systems input/output response in Simulink
I’m trying to simulate a plant with step input. This plant have two inputs and two outputs each input.
When i use ‘step’ command with MATLAB i’m getting 4 plots and that’s what i want.
But in simulink i can’t get 4 plots im getting just two.
and i’m using these simulink model;
How can get fix it ?
ThanksI’m trying to simulate a plant with step input. This plant have two inputs and two outputs each input.
When i use ‘step’ command with MATLAB i’m getting 4 plots and that’s what i want.
But in simulink i can’t get 4 plots im getting just two.
and i’m using these simulink model;
How can get fix it ?
Thanks I’m trying to simulate a plant with step input. This plant have two inputs and two outputs each input.
When i use ‘step’ command with MATLAB i’m getting 4 plots and that’s what i want.
But in simulink i can’t get 4 plots im getting just two.
and i’m using these simulink model;
How can get fix it ?
Thanks simulink, matlab, mimo MATLAB Answers — New Questions
Compiled report generator script fails.
I am receiving an error in a compiled script for report generator.
Here is the script:
makeDOMCompilable();
import mlreportgen.report.*
import mlreportgen.dom.*
rpt = Report(‘Test’,’pdf’);
%open(rpt);
% titlepage
%I = imread(img);
%imshow(I);
tp = TitlePage;
%location = pwd;
tp.Title = ‘Just a Test’;
tp.Image = which(strcat(‘duel.jpg’));
%tp.Author = Analyst();
tp.Publisher = ‘Mike Fisher’;
tp.PubDate = date();
tp.Subtitle = ‘GTG’;
add(rpt,tp);
add(rpt,LineBreak);
close(rpt);
rptview(rpt);
Runs fine in the command window. Compile it and run, get this error:
Error using mlreportgen.dom.Image
Invalid image type: .
Error in mlreportgen.report.TitlePage/getImageReporter
Error in mlreportgen.report.TitlePage/getImag
Error in mlreportgen.report.ReportForm/fillHole
Error in mlreportgen.report.TitlePage/processHole
Error in mlreportgen.report.ReportForm/fillForm
Error in mlreportgen.report.ReporterBase/getDocumentPart
Error in mlreportgen.report.ReporterBase/getImpl
Error in mlreportgen.report.internal.LockedForm.add
Error in mlreportgen.report.ReportBase/append
Error in mlreportgen.report.ReportBase/add
Error in JTest (line 28)I am receiving an error in a compiled script for report generator.
Here is the script:
makeDOMCompilable();
import mlreportgen.report.*
import mlreportgen.dom.*
rpt = Report(‘Test’,’pdf’);
%open(rpt);
% titlepage
%I = imread(img);
%imshow(I);
tp = TitlePage;
%location = pwd;
tp.Title = ‘Just a Test’;
tp.Image = which(strcat(‘duel.jpg’));
%tp.Author = Analyst();
tp.Publisher = ‘Mike Fisher’;
tp.PubDate = date();
tp.Subtitle = ‘GTG’;
add(rpt,tp);
add(rpt,LineBreak);
close(rpt);
rptview(rpt);
Runs fine in the command window. Compile it and run, get this error:
Error using mlreportgen.dom.Image
Invalid image type: .
Error in mlreportgen.report.TitlePage/getImageReporter
Error in mlreportgen.report.TitlePage/getImag
Error in mlreportgen.report.ReportForm/fillHole
Error in mlreportgen.report.TitlePage/processHole
Error in mlreportgen.report.ReportForm/fillForm
Error in mlreportgen.report.ReporterBase/getDocumentPart
Error in mlreportgen.report.ReporterBase/getImpl
Error in mlreportgen.report.internal.LockedForm.add
Error in mlreportgen.report.ReportBase/append
Error in mlreportgen.report.ReportBase/add
Error in JTest (line 28) I am receiving an error in a compiled script for report generator.
Here is the script:
makeDOMCompilable();
import mlreportgen.report.*
import mlreportgen.dom.*
rpt = Report(‘Test’,’pdf’);
%open(rpt);
% titlepage
%I = imread(img);
%imshow(I);
tp = TitlePage;
%location = pwd;
tp.Title = ‘Just a Test’;
tp.Image = which(strcat(‘duel.jpg’));
%tp.Author = Analyst();
tp.Publisher = ‘Mike Fisher’;
tp.PubDate = date();
tp.Subtitle = ‘GTG’;
add(rpt,tp);
add(rpt,LineBreak);
close(rpt);
rptview(rpt);
Runs fine in the command window. Compile it and run, get this error:
Error using mlreportgen.dom.Image
Invalid image type: .
Error in mlreportgen.report.TitlePage/getImageReporter
Error in mlreportgen.report.TitlePage/getImag
Error in mlreportgen.report.ReportForm/fillHole
Error in mlreportgen.report.TitlePage/processHole
Error in mlreportgen.report.ReportForm/fillForm
Error in mlreportgen.report.ReporterBase/getDocumentPart
Error in mlreportgen.report.ReporterBase/getImpl
Error in mlreportgen.report.internal.LockedForm.add
Error in mlreportgen.report.ReportBase/append
Error in mlreportgen.report.ReportBase/add
Error in JTest (line 28) generator, compiled, image MATLAB Answers — New Questions
how to open matlab in Ubuntu after installed
Right now the only way I know how to open matlab is opening terminal and type
/usr/local/MATLAB/R2024b/bin/matlab
Is there any other alternative that is easier, more straightforward?Right now the only way I know how to open matlab is opening terminal and type
/usr/local/MATLAB/R2024b/bin/matlab
Is there any other alternative that is easier, more straightforward? Right now the only way I know how to open matlab is opening terminal and type
/usr/local/MATLAB/R2024b/bin/matlab
Is there any other alternative that is easier, more straightforward? installation, linux MATLAB Answers — New Questions
simulating rolling 1 and 2 dice
I need to simulate rolling one dice 10 and 1000 times, and two dice 10 and 1000 times. I must add together the sums for the two dice. I then need to create a histogram with the PDF and CDF. I used a kernel density estimation to smooth the curves. I want to know if my code can be created into a loop to make things simpler. Here is what I have for the rolling 1 dice:
% Simulate 10 rolls, 1 die
roll_10 = randi([1, 6], 10, 1); %using the 1 because only rolling 1 die
mean_10=mean(roll_10);
std_10=std(roll_10);
figure;
histogram(roll_10)
% Plot the smooth PDF using a kernel density estimation
figure;
subplot(2, 1, 1);
ksdensity(roll_10); % Smooth PDF using kernel density estimation. each data point replaced with a wieghing function to estimate the pdf
title(‘Smooth PDF of Dice Rolls’);
xlabel(‘Dice Face Value’);
ylabel(‘Probability Density’);
xlim([0, 7]); % Limiting x-axis to dice face values
% Plot the smooth CDF using a kernel density estimation
subplot(2, 1, 2);
ksdensity(roll_10, ‘Cumulative’, true); % Smooth CDF
title(‘Smooth CDF of Dice Rolls’);
xlabel(‘Dice Face Value’);
ylabel(‘Cumulative Probability’);
xlim([0, 7]); % Limiting x-axis to dice face valuesI need to simulate rolling one dice 10 and 1000 times, and two dice 10 and 1000 times. I must add together the sums for the two dice. I then need to create a histogram with the PDF and CDF. I used a kernel density estimation to smooth the curves. I want to know if my code can be created into a loop to make things simpler. Here is what I have for the rolling 1 dice:
% Simulate 10 rolls, 1 die
roll_10 = randi([1, 6], 10, 1); %using the 1 because only rolling 1 die
mean_10=mean(roll_10);
std_10=std(roll_10);
figure;
histogram(roll_10)
% Plot the smooth PDF using a kernel density estimation
figure;
subplot(2, 1, 1);
ksdensity(roll_10); % Smooth PDF using kernel density estimation. each data point replaced with a wieghing function to estimate the pdf
title(‘Smooth PDF of Dice Rolls’);
xlabel(‘Dice Face Value’);
ylabel(‘Probability Density’);
xlim([0, 7]); % Limiting x-axis to dice face values
% Plot the smooth CDF using a kernel density estimation
subplot(2, 1, 2);
ksdensity(roll_10, ‘Cumulative’, true); % Smooth CDF
title(‘Smooth CDF of Dice Rolls’);
xlabel(‘Dice Face Value’);
ylabel(‘Cumulative Probability’);
xlim([0, 7]); % Limiting x-axis to dice face values I need to simulate rolling one dice 10 and 1000 times, and two dice 10 and 1000 times. I must add together the sums for the two dice. I then need to create a histogram with the PDF and CDF. I used a kernel density estimation to smooth the curves. I want to know if my code can be created into a loop to make things simpler. Here is what I have for the rolling 1 dice:
% Simulate 10 rolls, 1 die
roll_10 = randi([1, 6], 10, 1); %using the 1 because only rolling 1 die
mean_10=mean(roll_10);
std_10=std(roll_10);
figure;
histogram(roll_10)
% Plot the smooth PDF using a kernel density estimation
figure;
subplot(2, 1, 1);
ksdensity(roll_10); % Smooth PDF using kernel density estimation. each data point replaced with a wieghing function to estimate the pdf
title(‘Smooth PDF of Dice Rolls’);
xlabel(‘Dice Face Value’);
ylabel(‘Probability Density’);
xlim([0, 7]); % Limiting x-axis to dice face values
% Plot the smooth CDF using a kernel density estimation
subplot(2, 1, 2);
ksdensity(roll_10, ‘Cumulative’, true); % Smooth CDF
title(‘Smooth CDF of Dice Rolls’);
xlabel(‘Dice Face Value’);
ylabel(‘Cumulative Probability’);
xlim([0, 7]); % Limiting x-axis to dice face values random, mean, pdf MATLAB Answers — New Questions
Issues solving a system of 2, second order, differential equations with ode45
Hello everybody,
I am starting with Matlab to solve a system of 2 differential equations, second order.
My code is below. It works, but the output is totally wrong.
This code is something taken on matlab help center and adapted to my problem, to help me start.
I have written things in the code "#comment " where it’s not clear to me.
Your help would be very helpful to me.
Thanks a lot in advance.
clear all;
close all;
syms x(t) y(t)
%% Constants
Cd = 0,45 ;% drag coef aircraft [-]
Af = 2 ;% reference area aircraft [-]
m = 10 ;% total mass aircraft [kg]
g = 9.81 ;% acc° of gravity [m/s2]
Teta = 85 ;% launch angle [deg]
V0 = 83 ;% launch velocity [m/s]
rho_Air = 1,2 ;% air density [kg/m3]
t0 = 0; ;% time interval, initial t [s]
tf = 5400 ;% time interval, final t [s]
%% Initial Conditions
x_to = 0 ;% x(t=0)= 0 [m]
dx_t0 = V0*cosd(Teta) ;% x'(t=0)= V0*cosd(Teta) [m/s]
y_to = 0 ;% y'(t=0)= 0 [m]
dy_t0 = V0*sind(Teta) ;% x(t=0)= 0 [m/s]
y0 = [x_to dx_t0 y_to dy_t0 ] ;% vector initial conditions
%% System differential equations to be solved
eq1 = diff(x,2) == -( (Cd*Af*rho_Air)/(2*m) ) * diff(x,1) * (x^2 + y^2)^(1/2)
eq2 = diff(y,2) == – g – ( (Cd*Af*rho_Air)/(2*m) ) * diff(y,1) * ( (diff(x,1))^2 + (diff(y,1))^2 )^(1/2)
%% variables
vars = [x(t); y(t)]
V = odeToVectorField([eq1,eq2])
M = matlabFunction(V,’vars’, {‘t’,’Y’});
% #comment: why the variable x doesn’t appear here ? as I solve on x(t) and
% y(t) -> in V I call eq1 and eq2, then it’s x(t) and y(t)
interval = [t0 tf]; %time interval
ySol = ode45(M,interval,y0);
% #comment: vector y0 containts the boundary conditions for both x and y.
% As here I solve on y, why do we have boundary conditions in x as well ?
% is the function ode capable to make the difference in between boudady
% conditions for x and y ?
tValues = linspace(interval(1),interval(2),1000);
yValues = deval(ySol,tValues,1); %number 1 denotes first position likewise you can mention 2 to 6 for the next 5 positions
plot(tValues,yValues) %if you want to plot position vs time just swap here
% #comment: I need to solve on x as well
% thank you !Hello everybody,
I am starting with Matlab to solve a system of 2 differential equations, second order.
My code is below. It works, but the output is totally wrong.
This code is something taken on matlab help center and adapted to my problem, to help me start.
I have written things in the code "#comment " where it’s not clear to me.
Your help would be very helpful to me.
Thanks a lot in advance.
clear all;
close all;
syms x(t) y(t)
%% Constants
Cd = 0,45 ;% drag coef aircraft [-]
Af = 2 ;% reference area aircraft [-]
m = 10 ;% total mass aircraft [kg]
g = 9.81 ;% acc° of gravity [m/s2]
Teta = 85 ;% launch angle [deg]
V0 = 83 ;% launch velocity [m/s]
rho_Air = 1,2 ;% air density [kg/m3]
t0 = 0; ;% time interval, initial t [s]
tf = 5400 ;% time interval, final t [s]
%% Initial Conditions
x_to = 0 ;% x(t=0)= 0 [m]
dx_t0 = V0*cosd(Teta) ;% x'(t=0)= V0*cosd(Teta) [m/s]
y_to = 0 ;% y'(t=0)= 0 [m]
dy_t0 = V0*sind(Teta) ;% x(t=0)= 0 [m/s]
y0 = [x_to dx_t0 y_to dy_t0 ] ;% vector initial conditions
%% System differential equations to be solved
eq1 = diff(x,2) == -( (Cd*Af*rho_Air)/(2*m) ) * diff(x,1) * (x^2 + y^2)^(1/2)
eq2 = diff(y,2) == – g – ( (Cd*Af*rho_Air)/(2*m) ) * diff(y,1) * ( (diff(x,1))^2 + (diff(y,1))^2 )^(1/2)
%% variables
vars = [x(t); y(t)]
V = odeToVectorField([eq1,eq2])
M = matlabFunction(V,’vars’, {‘t’,’Y’});
% #comment: why the variable x doesn’t appear here ? as I solve on x(t) and
% y(t) -> in V I call eq1 and eq2, then it’s x(t) and y(t)
interval = [t0 tf]; %time interval
ySol = ode45(M,interval,y0);
% #comment: vector y0 containts the boundary conditions for both x and y.
% As here I solve on y, why do we have boundary conditions in x as well ?
% is the function ode capable to make the difference in between boudady
% conditions for x and y ?
tValues = linspace(interval(1),interval(2),1000);
yValues = deval(ySol,tValues,1); %number 1 denotes first position likewise you can mention 2 to 6 for the next 5 positions
plot(tValues,yValues) %if you want to plot position vs time just swap here
% #comment: I need to solve on x as well
% thank you ! Hello everybody,
I am starting with Matlab to solve a system of 2 differential equations, second order.
My code is below. It works, but the output is totally wrong.
This code is something taken on matlab help center and adapted to my problem, to help me start.
I have written things in the code "#comment " where it’s not clear to me.
Your help would be very helpful to me.
Thanks a lot in advance.
clear all;
close all;
syms x(t) y(t)
%% Constants
Cd = 0,45 ;% drag coef aircraft [-]
Af = 2 ;% reference area aircraft [-]
m = 10 ;% total mass aircraft [kg]
g = 9.81 ;% acc° of gravity [m/s2]
Teta = 85 ;% launch angle [deg]
V0 = 83 ;% launch velocity [m/s]
rho_Air = 1,2 ;% air density [kg/m3]
t0 = 0; ;% time interval, initial t [s]
tf = 5400 ;% time interval, final t [s]
%% Initial Conditions
x_to = 0 ;% x(t=0)= 0 [m]
dx_t0 = V0*cosd(Teta) ;% x'(t=0)= V0*cosd(Teta) [m/s]
y_to = 0 ;% y'(t=0)= 0 [m]
dy_t0 = V0*sind(Teta) ;% x(t=0)= 0 [m/s]
y0 = [x_to dx_t0 y_to dy_t0 ] ;% vector initial conditions
%% System differential equations to be solved
eq1 = diff(x,2) == -( (Cd*Af*rho_Air)/(2*m) ) * diff(x,1) * (x^2 + y^2)^(1/2)
eq2 = diff(y,2) == – g – ( (Cd*Af*rho_Air)/(2*m) ) * diff(y,1) * ( (diff(x,1))^2 + (diff(y,1))^2 )^(1/2)
%% variables
vars = [x(t); y(t)]
V = odeToVectorField([eq1,eq2])
M = matlabFunction(V,’vars’, {‘t’,’Y’});
% #comment: why the variable x doesn’t appear here ? as I solve on x(t) and
% y(t) -> in V I call eq1 and eq2, then it’s x(t) and y(t)
interval = [t0 tf]; %time interval
ySol = ode45(M,interval,y0);
% #comment: vector y0 containts the boundary conditions for both x and y.
% As here I solve on y, why do we have boundary conditions in x as well ?
% is the function ode capable to make the difference in between boudady
% conditions for x and y ?
tValues = linspace(interval(1),interval(2),1000);
yValues = deval(ySol,tValues,1); %number 1 denotes first position likewise you can mention 2 to 6 for the next 5 positions
plot(tValues,yValues) %if you want to plot position vs time just swap here
% #comment: I need to solve on x as well
% thank you ! solving ode, ode45, system 2 ode second order MATLAB Answers — New Questions
Plot lines with curves from csv file
Hi,
I have a csv/txt file that contains x,y,z and also the rotation center x and rotation center y data. The data are basically the coordinates of a path that a robot follows. The robot can make his path in a straight line and also in curves. How can I use the rotation center x and y coordinates in my data to plot the curves.
My current plot has only straight lines. But as you can see in the image attached, the actual path inlcudes curves around corners based on the rotation center x and y data. The following code is obviously not enough.
figure(1)
plot(Data.PosX,Data.PosY)Hi,
I have a csv/txt file that contains x,y,z and also the rotation center x and rotation center y data. The data are basically the coordinates of a path that a robot follows. The robot can make his path in a straight line and also in curves. How can I use the rotation center x and y coordinates in my data to plot the curves.
My current plot has only straight lines. But as you can see in the image attached, the actual path inlcudes curves around corners based on the rotation center x and y data. The following code is obviously not enough.
figure(1)
plot(Data.PosX,Data.PosY) Hi,
I have a csv/txt file that contains x,y,z and also the rotation center x and rotation center y data. The data are basically the coordinates of a path that a robot follows. The robot can make his path in a straight line and also in curves. How can I use the rotation center x and y coordinates in my data to plot the curves.
My current plot has only straight lines. But as you can see in the image attached, the actual path inlcudes curves around corners based on the rotation center x and y data. The following code is obviously not enough.
figure(1)
plot(Data.PosX,Data.PosY) plot, 2d, curves, line, scatter, rotation, center MATLAB Answers — New Questions
Writing tables within a for loop
Hi all,
I’m trying to make a for loop to process some EEG data. The final output is (1×96) for each participant which is finally working great, however, now I’m having issues writing the data/ looping through the participants. I’ve attached what the output looks like for one particpant as that is how far I can get. Below is what I’m trying to use unnsuccessfully. Any help is greatly appreciated!
SubjectNum = { ’01-02′ ’01-03′ };
resultsFileName = [fullfile(baseDir, ‘MATLAB_Output’, ‘DIVINE.75results.xlsx’)];
for k = 1:length(SubjectNum)
…. (whole bunch of steps)
RelativePowerResults = table(ID,channelsLabel,relativeDelta2,relativeTheta2,relativeAlpha2,relativeBeta2,relativeGamma2)
% unstack resulting in (1 row with 96 columns)
RelativePowerResults_Wide = unstack(RelativePowerResults,"relative"+["Alpha2","Delta2","Theta2","Beta2","Gamma2"],’channelsLabel’);
if k == 1
% First subject, with variable names
writetable(RelativePowerResults_Wide, resultsFileName, ‘Sheet’, 1, ‘Range’, RANGE{k});
else
% For subsequent subjects, write without variable names
writetable(RelativePowerResults_Wide, resultsFileName, ‘Sheet’, 1, ‘Range’,RANGE{k}, ‘WriteVariableNames’, false);
endHi all,
I’m trying to make a for loop to process some EEG data. The final output is (1×96) for each participant which is finally working great, however, now I’m having issues writing the data/ looping through the participants. I’ve attached what the output looks like for one particpant as that is how far I can get. Below is what I’m trying to use unnsuccessfully. Any help is greatly appreciated!
SubjectNum = { ’01-02′ ’01-03′ };
resultsFileName = [fullfile(baseDir, ‘MATLAB_Output’, ‘DIVINE.75results.xlsx’)];
for k = 1:length(SubjectNum)
…. (whole bunch of steps)
RelativePowerResults = table(ID,channelsLabel,relativeDelta2,relativeTheta2,relativeAlpha2,relativeBeta2,relativeGamma2)
% unstack resulting in (1 row with 96 columns)
RelativePowerResults_Wide = unstack(RelativePowerResults,"relative"+["Alpha2","Delta2","Theta2","Beta2","Gamma2"],’channelsLabel’);
if k == 1
% First subject, with variable names
writetable(RelativePowerResults_Wide, resultsFileName, ‘Sheet’, 1, ‘Range’, RANGE{k});
else
% For subsequent subjects, write without variable names
writetable(RelativePowerResults_Wide, resultsFileName, ‘Sheet’, 1, ‘Range’,RANGE{k}, ‘WriteVariableNames’, false);
end Hi all,
I’m trying to make a for loop to process some EEG data. The final output is (1×96) for each participant which is finally working great, however, now I’m having issues writing the data/ looping through the participants. I’ve attached what the output looks like for one particpant as that is how far I can get. Below is what I’m trying to use unnsuccessfully. Any help is greatly appreciated!
SubjectNum = { ’01-02′ ’01-03′ };
resultsFileName = [fullfile(baseDir, ‘MATLAB_Output’, ‘DIVINE.75results.xlsx’)];
for k = 1:length(SubjectNum)
…. (whole bunch of steps)
RelativePowerResults = table(ID,channelsLabel,relativeDelta2,relativeTheta2,relativeAlpha2,relativeBeta2,relativeGamma2)
% unstack resulting in (1 row with 96 columns)
RelativePowerResults_Wide = unstack(RelativePowerResults,"relative"+["Alpha2","Delta2","Theta2","Beta2","Gamma2"],’channelsLabel’);
if k == 1
% First subject, with variable names
writetable(RelativePowerResults_Wide, resultsFileName, ‘Sheet’, 1, ‘Range’, RANGE{k});
else
% For subsequent subjects, write without variable names
writetable(RelativePowerResults_Wide, resultsFileName, ‘Sheet’, 1, ‘Range’,RANGE{k}, ‘WriteVariableNames’, false);
end for loop, eeg MATLAB Answers — New Questions
defining upper and lower limits of a matrix
Hello all I have a smaller question and a larger question.
Small question: In the attached ‘viscosity_test.mat’ file is there a way to set the minimum value to 1e19? Is the process similar if I decide I want to set a maximum value?
Larger question: I am running a finite difference numerical model on an uploaded .png file (shown below). I believe the shape boundary is causing artificially low and high values to be output. Is there a way to troubleshoot this that doesn’t involve going through and manipulating the minimum and maximum values after the model runs? I can provide more details if that is unclear.
Thank you for any help!Hello all I have a smaller question and a larger question.
Small question: In the attached ‘viscosity_test.mat’ file is there a way to set the minimum value to 1e19? Is the process similar if I decide I want to set a maximum value?
Larger question: I am running a finite difference numerical model on an uploaded .png file (shown below). I believe the shape boundary is causing artificially low and high values to be output. Is there a way to troubleshoot this that doesn’t involve going through and manipulating the minimum and maximum values after the model runs? I can provide more details if that is unclear.
Thank you for any help! Hello all I have a smaller question and a larger question.
Small question: In the attached ‘viscosity_test.mat’ file is there a way to set the minimum value to 1e19? Is the process similar if I decide I want to set a maximum value?
Larger question: I am running a finite difference numerical model on an uploaded .png file (shown below). I believe the shape boundary is causing artificially low and high values to be output. Is there a way to troubleshoot this that doesn’t involve going through and manipulating the minimum and maximum values after the model runs? I can provide more details if that is unclear.
Thank you for any help! matrix manipulation MATLAB Answers — New Questions
How can I make output for input with continuous number input on DTMF which is based on Goertzel algorithm?
Hello. I designed the DTMF decoder function based on goertzel algorithm. When I put input with 123-456-7890_40 and 404-894-2714_30, The function prints out with output with 123-456-7890 and 404-894-2714. However, when I put input with 123-555-4709_25, output is ,
Invalid number or insufficient digits
‘. I tried to fix the code, but I am not sure what should I do. Could you please let me know what should I add or edit? Thanks.Hello. I designed the DTMF decoder function based on goertzel algorithm. When I put input with 123-456-7890_40 and 404-894-2714_30, The function prints out with output with 123-456-7890 and 404-894-2714. However, when I put input with 123-555-4709_25, output is ,
Invalid number or insufficient digits
‘. I tried to fix the code, but I am not sure what should I do. Could you please let me know what should I add or edit? Thanks. Hello. I designed the DTMF decoder function based on goertzel algorithm. When I put input with 123-456-7890_40 and 404-894-2714_30, The function prints out with output with 123-456-7890 and 404-894-2714. However, when I put input with 123-555-4709_25, output is ,
Invalid number or insufficient digits
‘. I tried to fix the code, but I am not sure what should I do. Could you please let me know what should I add or edit? Thanks. dtmf, goertzel MATLAB Answers — New Questions
Unable to load initial operating point after modifying blockparameters.
Hi,
I need to run a large simulink model under varying operating conditions (resistances between nodes). I have been trying to save the operating state, changing block parameters (struct which has the resistance values), load the saved as initial state and continue. But I get the error:
‘Simulink cannot load the initial operating point because the model, ‘mymodel’, was changed after the operating point was saved. Run the simulation again and resave the operating point.’
I understood that unless datatype, dimensions or connections change, this should not happen, but that is not the case here. I also disabled the block parameter changes, and then the model runs fine.
If this is impossible how can this be achieved? (i.e. block parameters defined via strcuts in the workplace needs to change at a particular time).Hi,
I need to run a large simulink model under varying operating conditions (resistances between nodes). I have been trying to save the operating state, changing block parameters (struct which has the resistance values), load the saved as initial state and continue. But I get the error:
‘Simulink cannot load the initial operating point because the model, ‘mymodel’, was changed after the operating point was saved. Run the simulation again and resave the operating point.’
I understood that unless datatype, dimensions or connections change, this should not happen, but that is not the case here. I also disabled the block parameter changes, and then the model runs fine.
If this is impossible how can this be achieved? (i.e. block parameters defined via strcuts in the workplace needs to change at a particular time). Hi,
I need to run a large simulink model under varying operating conditions (resistances between nodes). I have been trying to save the operating state, changing block parameters (struct which has the resistance values), load the saved as initial state and continue. But I get the error:
‘Simulink cannot load the initial operating point because the model, ‘mymodel’, was changed after the operating point was saved. Run the simulation again and resave the operating point.’
I understood that unless datatype, dimensions or connections change, this should not happen, but that is not the case here. I also disabled the block parameter changes, and then the model runs fine.
If this is impossible how can this be achieved? (i.e. block parameters defined via strcuts in the workplace needs to change at a particular time). matlab, simscape, simstate MATLAB Answers — New Questions
Using 3 “y” axes for multiple plot
Hello,
I am working with multiple plots in MATLAB and I would like to use three different "y" axis for the different axes within a single figure. I have no problem using two "y" axes with yyaxis, I can’t include that function in my for loop (this loop reads the data from each column to be plotted from the Excel file). I read about a function called addaxis, but I don’t know how to use it.
Also, I would like the plots to have different colors for each "y" axis, since MATLAB defaults to red for Y1 and blue for Y2. Any ideas on how to achieve this?
Any suggestions would be greatly appreciated!
Best Regards!
Lucas.
clc;
clear;
nombre_excel = ‘Hoja_fuente.xlsx’;
datos = readtable (nombre_excel);
encabezados = datos.Properties.VariableNames(2:end);
encabezados = strrep(encabezados, ‘_’, ‘ ‘);
t = datetime(datos.Tiempo,’ConvertFrom’, ‘datenum’, ‘Format’, ‘HH:mm:ss’); %Si da probemas: sustituir ‘datenum’ por ‘excel’
numero_columnas=size(datos,2) – 1;
fig = figure(‘Name’,’Representación interactiva MATLAB’, ‘NumberTitle’,’off’, ‘Color’, ‘w’);
hold on;
grid on;
for i=2:numero_columnas+1
y_i = datos(:,i);
y_i = table2array(y_i);
if max(y_i) <= 100
yyaxis right
plot(t, y_i, ‘LineWidth’, 1.5, ‘DisplayName’, encabezados{i-1}, SeriesIndex = 1, marker=’.’, markersize = 1, color = ‘r’);
end
if max(y_i) > 100
yyaxis left
plot(t, y_i, ‘LineWidth’, 1.5, ‘DisplayName’, encabezados{i-1}, SeriesIndex = 1, marker=’.’, markersize = 1, color = ‘b’); %[‘Y_’ num2str(i-1)]
end
end
title(‘Gráfica Interactiva’);
legend(‘show’);
xlabel(‘Tiempo( hh:mm:ss )’, ‘FontSize’, 12);
%ylabel(encabezados, ‘Rotation’, 0, ‘Color’, ‘b’);
ax=gca;
ax.XAxis.Exponent = 0;
ax.XAxis.TickLabelFormat = ‘HH:mm:ss’;
axis tight;
ax.XAxis.SecondaryLabelFormatMode = ‘manual’;
set(gca, ‘Position’, [0.056770833333333,0.157667386609071,0.894270833333333,0.809935205183586]);
legend(‘Location’, ‘southoutside’, ‘NumColumns’, 6, ‘Orientation’, ‘horizontal’, ‘NumColumnsMode’,’manual’, ‘Interpreter’,’none’, ‘FontSize’, 8, ‘FontWeight’, ‘bold’, ‘FontName’, ‘Arial Narrow’, ‘box’, ‘on’);
set(legend, ‘IconColumnWidth’, 15, ‘Position’, [0.004678527128273,0.041036717062635,0.988802104021113,0.058815920456996]);
format long g;
This code is working but It can only plot 2 "y" axes; but if I try the addaxis in order to implement the third "y" axis, my code It´s not working:
clc;
clear;
nombre_excel = ‘Hoja_fuente.xlsx’;
datos = readtable (nombre_excel);
encabezados = datos.Properties.VariableNames(2:end);
encabezados = strrep(encabezados, ‘_’, ‘ ‘);
t = datetime(datos.Tiempo,’ConvertFrom’, ‘datenum’, ‘Format’, ‘HH:mm:ss’); %Si da probemas: sustituir ‘datenum’ por ‘excel’
numero_columnas=size(datos,2) – 1;
fig = figure(‘Name’,’Representación interactiva MATLAB DQA’, ‘NumberTitle’,’off’, ‘Color’, ‘w’); %Preguntar si NumberTitle on o off
hold on;
grid on;
for i=2:numero_columnas+1
y_i = datos(:,i);
y_i = table2array(y_i);
if max(y_i) <= 20
addaxis(t, y_i, [0 20],’LineWidth’,1.3,’Color’,’b’)
plot(t, y_i, ‘LineWidth’, 1.5, ‘DisplayName’, encabezados{i-1}, ‘SeriesIndex’, 1, ‘Marker’, ‘.’, ‘MarkerSize’, 1, ‘Color’, ‘green’);
end
if 20 < max(y_i) && max(y_i) <= 100
addaxis(t, y_i, [0 100], ‘LineWidth’,1.3,’Color’,’r’)
plot(t, y_i, ‘LineWidth’, 1.5, ‘DisplayName’, encabezados{i-1}, SeriesIndex = 1, marker=’.’, markersize = 1, color = ‘red’); %[‘Y_’ num2str(i-1)]
end
if max(y_i) > 100
addaxis(t, y_i, [0 max(y_i)],’LineWidth’,1.3,’Color’,’g’)
plot(t, y_i, ‘LineWidth’, 1.5, ‘DisplayName’, encabezados{i-1}, SeriesIndex = 1, marker=’.’, markersize = 1, color = ‘b’); %[‘Y_’ num2str(i-1)]
end
end
title(‘Gráfica Interactiva DiagnóstiQA’);
legend(‘show’);
xlabel(‘Tiempo( hh:mm:ss )’, ‘FontSize’, 12);
%ylabel(encabezados, ‘Rotation’, 0, ‘Color’, ‘b’);
ax=gca;
ax.XAxis.Exponent = 0;
ax.XAxis.TickLabelFormat = ‘HH:mm:ss’; %QUITAR ESTA LINEA DE CODIGO SI PREFERIMOS FORMATO TEMPORAL mm:ss
axis tight; %INSTRUCCIONES: tight, tickaligned o padded %en vez de axis puedo usar xlim o ylim si solo quiero ajustar 1 de los ejes
ax.XAxis.SecondaryLabelFormatMode = ‘manual’; %ESTO SOLUCIONA EL 31 -1!
set(gca, ‘Position’, [0.056770833333333,0.157667386609071,0.894270833333333,0.809935205183586]); %El segundo numero es el margen desde el borde inferior de la ventana y el cuarto número es la altura de los ejes
legend(‘Location’, ‘southoutside’, ‘NumColumns’, 6, ‘Orientation’, ‘horizontal’, ‘NumColumnsMode’,’manual’, ‘Interpreter’,’none’, ‘FontSize’, 8, ‘FontWeight’, ‘bold’, ‘FontName’, ‘Arial Narrow’, ‘box’, ‘on’);
set(legend, ‘IconColumnWidth’, 15, ‘Position’, [0.004678527128273,0.041036717062635,0.988802104021113,0.058815920456996]);
format long g;Hello,
I am working with multiple plots in MATLAB and I would like to use three different "y" axis for the different axes within a single figure. I have no problem using two "y" axes with yyaxis, I can’t include that function in my for loop (this loop reads the data from each column to be plotted from the Excel file). I read about a function called addaxis, but I don’t know how to use it.
Also, I would like the plots to have different colors for each "y" axis, since MATLAB defaults to red for Y1 and blue for Y2. Any ideas on how to achieve this?
Any suggestions would be greatly appreciated!
Best Regards!
Lucas.
clc;
clear;
nombre_excel = ‘Hoja_fuente.xlsx’;
datos = readtable (nombre_excel);
encabezados = datos.Properties.VariableNames(2:end);
encabezados = strrep(encabezados, ‘_’, ‘ ‘);
t = datetime(datos.Tiempo,’ConvertFrom’, ‘datenum’, ‘Format’, ‘HH:mm:ss’); %Si da probemas: sustituir ‘datenum’ por ‘excel’
numero_columnas=size(datos,2) – 1;
fig = figure(‘Name’,’Representación interactiva MATLAB’, ‘NumberTitle’,’off’, ‘Color’, ‘w’);
hold on;
grid on;
for i=2:numero_columnas+1
y_i = datos(:,i);
y_i = table2array(y_i);
if max(y_i) <= 100
yyaxis right
plot(t, y_i, ‘LineWidth’, 1.5, ‘DisplayName’, encabezados{i-1}, SeriesIndex = 1, marker=’.’, markersize = 1, color = ‘r’);
end
if max(y_i) > 100
yyaxis left
plot(t, y_i, ‘LineWidth’, 1.5, ‘DisplayName’, encabezados{i-1}, SeriesIndex = 1, marker=’.’, markersize = 1, color = ‘b’); %[‘Y_’ num2str(i-1)]
end
end
title(‘Gráfica Interactiva’);
legend(‘show’);
xlabel(‘Tiempo( hh:mm:ss )’, ‘FontSize’, 12);
%ylabel(encabezados, ‘Rotation’, 0, ‘Color’, ‘b’);
ax=gca;
ax.XAxis.Exponent = 0;
ax.XAxis.TickLabelFormat = ‘HH:mm:ss’;
axis tight;
ax.XAxis.SecondaryLabelFormatMode = ‘manual’;
set(gca, ‘Position’, [0.056770833333333,0.157667386609071,0.894270833333333,0.809935205183586]);
legend(‘Location’, ‘southoutside’, ‘NumColumns’, 6, ‘Orientation’, ‘horizontal’, ‘NumColumnsMode’,’manual’, ‘Interpreter’,’none’, ‘FontSize’, 8, ‘FontWeight’, ‘bold’, ‘FontName’, ‘Arial Narrow’, ‘box’, ‘on’);
set(legend, ‘IconColumnWidth’, 15, ‘Position’, [0.004678527128273,0.041036717062635,0.988802104021113,0.058815920456996]);
format long g;
This code is working but It can only plot 2 "y" axes; but if I try the addaxis in order to implement the third "y" axis, my code It´s not working:
clc;
clear;
nombre_excel = ‘Hoja_fuente.xlsx’;
datos = readtable (nombre_excel);
encabezados = datos.Properties.VariableNames(2:end);
encabezados = strrep(encabezados, ‘_’, ‘ ‘);
t = datetime(datos.Tiempo,’ConvertFrom’, ‘datenum’, ‘Format’, ‘HH:mm:ss’); %Si da probemas: sustituir ‘datenum’ por ‘excel’
numero_columnas=size(datos,2) – 1;
fig = figure(‘Name’,’Representación interactiva MATLAB DQA’, ‘NumberTitle’,’off’, ‘Color’, ‘w’); %Preguntar si NumberTitle on o off
hold on;
grid on;
for i=2:numero_columnas+1
y_i = datos(:,i);
y_i = table2array(y_i);
if max(y_i) <= 20
addaxis(t, y_i, [0 20],’LineWidth’,1.3,’Color’,’b’)
plot(t, y_i, ‘LineWidth’, 1.5, ‘DisplayName’, encabezados{i-1}, ‘SeriesIndex’, 1, ‘Marker’, ‘.’, ‘MarkerSize’, 1, ‘Color’, ‘green’);
end
if 20 < max(y_i) && max(y_i) <= 100
addaxis(t, y_i, [0 100], ‘LineWidth’,1.3,’Color’,’r’)
plot(t, y_i, ‘LineWidth’, 1.5, ‘DisplayName’, encabezados{i-1}, SeriesIndex = 1, marker=’.’, markersize = 1, color = ‘red’); %[‘Y_’ num2str(i-1)]
end
if max(y_i) > 100
addaxis(t, y_i, [0 max(y_i)],’LineWidth’,1.3,’Color’,’g’)
plot(t, y_i, ‘LineWidth’, 1.5, ‘DisplayName’, encabezados{i-1}, SeriesIndex = 1, marker=’.’, markersize = 1, color = ‘b’); %[‘Y_’ num2str(i-1)]
end
end
title(‘Gráfica Interactiva DiagnóstiQA’);
legend(‘show’);
xlabel(‘Tiempo( hh:mm:ss )’, ‘FontSize’, 12);
%ylabel(encabezados, ‘Rotation’, 0, ‘Color’, ‘b’);
ax=gca;
ax.XAxis.Exponent = 0;
ax.XAxis.TickLabelFormat = ‘HH:mm:ss’; %QUITAR ESTA LINEA DE CODIGO SI PREFERIMOS FORMATO TEMPORAL mm:ss
axis tight; %INSTRUCCIONES: tight, tickaligned o padded %en vez de axis puedo usar xlim o ylim si solo quiero ajustar 1 de los ejes
ax.XAxis.SecondaryLabelFormatMode = ‘manual’; %ESTO SOLUCIONA EL 31 -1!
set(gca, ‘Position’, [0.056770833333333,0.157667386609071,0.894270833333333,0.809935205183586]); %El segundo numero es el margen desde el borde inferior de la ventana y el cuarto número es la altura de los ejes
legend(‘Location’, ‘southoutside’, ‘NumColumns’, 6, ‘Orientation’, ‘horizontal’, ‘NumColumnsMode’,’manual’, ‘Interpreter’,’none’, ‘FontSize’, 8, ‘FontWeight’, ‘bold’, ‘FontName’, ‘Arial Narrow’, ‘box’, ‘on’);
set(legend, ‘IconColumnWidth’, 15, ‘Position’, [0.004678527128273,0.041036717062635,0.988802104021113,0.058815920456996]);
format long g; Hello,
I am working with multiple plots in MATLAB and I would like to use three different "y" axis for the different axes within a single figure. I have no problem using two "y" axes with yyaxis, I can’t include that function in my for loop (this loop reads the data from each column to be plotted from the Excel file). I read about a function called addaxis, but I don’t know how to use it.
Also, I would like the plots to have different colors for each "y" axis, since MATLAB defaults to red for Y1 and blue for Y2. Any ideas on how to achieve this?
Any suggestions would be greatly appreciated!
Best Regards!
Lucas.
clc;
clear;
nombre_excel = ‘Hoja_fuente.xlsx’;
datos = readtable (nombre_excel);
encabezados = datos.Properties.VariableNames(2:end);
encabezados = strrep(encabezados, ‘_’, ‘ ‘);
t = datetime(datos.Tiempo,’ConvertFrom’, ‘datenum’, ‘Format’, ‘HH:mm:ss’); %Si da probemas: sustituir ‘datenum’ por ‘excel’
numero_columnas=size(datos,2) – 1;
fig = figure(‘Name’,’Representación interactiva MATLAB’, ‘NumberTitle’,’off’, ‘Color’, ‘w’);
hold on;
grid on;
for i=2:numero_columnas+1
y_i = datos(:,i);
y_i = table2array(y_i);
if max(y_i) <= 100
yyaxis right
plot(t, y_i, ‘LineWidth’, 1.5, ‘DisplayName’, encabezados{i-1}, SeriesIndex = 1, marker=’.’, markersize = 1, color = ‘r’);
end
if max(y_i) > 100
yyaxis left
plot(t, y_i, ‘LineWidth’, 1.5, ‘DisplayName’, encabezados{i-1}, SeriesIndex = 1, marker=’.’, markersize = 1, color = ‘b’); %[‘Y_’ num2str(i-1)]
end
end
title(‘Gráfica Interactiva’);
legend(‘show’);
xlabel(‘Tiempo( hh:mm:ss )’, ‘FontSize’, 12);
%ylabel(encabezados, ‘Rotation’, 0, ‘Color’, ‘b’);
ax=gca;
ax.XAxis.Exponent = 0;
ax.XAxis.TickLabelFormat = ‘HH:mm:ss’;
axis tight;
ax.XAxis.SecondaryLabelFormatMode = ‘manual’;
set(gca, ‘Position’, [0.056770833333333,0.157667386609071,0.894270833333333,0.809935205183586]);
legend(‘Location’, ‘southoutside’, ‘NumColumns’, 6, ‘Orientation’, ‘horizontal’, ‘NumColumnsMode’,’manual’, ‘Interpreter’,’none’, ‘FontSize’, 8, ‘FontWeight’, ‘bold’, ‘FontName’, ‘Arial Narrow’, ‘box’, ‘on’);
set(legend, ‘IconColumnWidth’, 15, ‘Position’, [0.004678527128273,0.041036717062635,0.988802104021113,0.058815920456996]);
format long g;
This code is working but It can only plot 2 "y" axes; but if I try the addaxis in order to implement the third "y" axis, my code It´s not working:
clc;
clear;
nombre_excel = ‘Hoja_fuente.xlsx’;
datos = readtable (nombre_excel);
encabezados = datos.Properties.VariableNames(2:end);
encabezados = strrep(encabezados, ‘_’, ‘ ‘);
t = datetime(datos.Tiempo,’ConvertFrom’, ‘datenum’, ‘Format’, ‘HH:mm:ss’); %Si da probemas: sustituir ‘datenum’ por ‘excel’
numero_columnas=size(datos,2) – 1;
fig = figure(‘Name’,’Representación interactiva MATLAB DQA’, ‘NumberTitle’,’off’, ‘Color’, ‘w’); %Preguntar si NumberTitle on o off
hold on;
grid on;
for i=2:numero_columnas+1
y_i = datos(:,i);
y_i = table2array(y_i);
if max(y_i) <= 20
addaxis(t, y_i, [0 20],’LineWidth’,1.3,’Color’,’b’)
plot(t, y_i, ‘LineWidth’, 1.5, ‘DisplayName’, encabezados{i-1}, ‘SeriesIndex’, 1, ‘Marker’, ‘.’, ‘MarkerSize’, 1, ‘Color’, ‘green’);
end
if 20 < max(y_i) && max(y_i) <= 100
addaxis(t, y_i, [0 100], ‘LineWidth’,1.3,’Color’,’r’)
plot(t, y_i, ‘LineWidth’, 1.5, ‘DisplayName’, encabezados{i-1}, SeriesIndex = 1, marker=’.’, markersize = 1, color = ‘red’); %[‘Y_’ num2str(i-1)]
end
if max(y_i) > 100
addaxis(t, y_i, [0 max(y_i)],’LineWidth’,1.3,’Color’,’g’)
plot(t, y_i, ‘LineWidth’, 1.5, ‘DisplayName’, encabezados{i-1}, SeriesIndex = 1, marker=’.’, markersize = 1, color = ‘b’); %[‘Y_’ num2str(i-1)]
end
end
title(‘Gráfica Interactiva DiagnóstiQA’);
legend(‘show’);
xlabel(‘Tiempo( hh:mm:ss )’, ‘FontSize’, 12);
%ylabel(encabezados, ‘Rotation’, 0, ‘Color’, ‘b’);
ax=gca;
ax.XAxis.Exponent = 0;
ax.XAxis.TickLabelFormat = ‘HH:mm:ss’; %QUITAR ESTA LINEA DE CODIGO SI PREFERIMOS FORMATO TEMPORAL mm:ss
axis tight; %INSTRUCCIONES: tight, tickaligned o padded %en vez de axis puedo usar xlim o ylim si solo quiero ajustar 1 de los ejes
ax.XAxis.SecondaryLabelFormatMode = ‘manual’; %ESTO SOLUCIONA EL 31 -1!
set(gca, ‘Position’, [0.056770833333333,0.157667386609071,0.894270833333333,0.809935205183586]); %El segundo numero es el margen desde el borde inferior de la ventana y el cuarto número es la altura de los ejes
legend(‘Location’, ‘southoutside’, ‘NumColumns’, 6, ‘Orientation’, ‘horizontal’, ‘NumColumnsMode’,’manual’, ‘Interpreter’,’none’, ‘FontSize’, 8, ‘FontWeight’, ‘bold’, ‘FontName’, ‘Arial Narrow’, ‘box’, ‘on’);
set(legend, ‘IconColumnWidth’, 15, ‘Position’, [0.004678527128273,0.041036717062635,0.988802104021113,0.058815920456996]);
format long g; plot, label MATLAB Answers — New Questions
How can I prevent MATLAB from copying a SIMSCAPE model to the current folder?
Hi,
I have a simscape model that I call from different folders (that reflect different scenarios). I have a script where I add the locaiton of the master model in path and then run the model. However, each time I do this, I notice that a duplicate copy of the simscape model is created in the current folder. This is uninteded. Why does MATLAB do this? Is there a way to avoid this file duplication and keep just the original added via path?
Thanks!Hi,
I have a simscape model that I call from different folders (that reflect different scenarios). I have a script where I add the locaiton of the master model in path and then run the model. However, each time I do this, I notice that a duplicate copy of the simscape model is created in the current folder. This is uninteded. Why does MATLAB do this? Is there a way to avoid this file duplication and keep just the original added via path?
Thanks! Hi,
I have a simscape model that I call from different folders (that reflect different scenarios). I have a script where I add the locaiton of the master model in path and then run the model. However, each time I do this, I notice that a duplicate copy of the simscape model is created in the current folder. This is uninteded. Why does MATLAB do this? Is there a way to avoid this file duplication and keep just the original added via path?
Thanks! simscape, file management MATLAB Answers — New Questions
sprintf
I’m trying to get sprintf to print out a line that says:
‘for event —– stations pass the criteria test=’
where it will list the results for my stations vertically like:
U02B.HHZf
U04B.HHZf
U05B.HHZf
U06B.HHZf
and so on. I can’t seem to get it to do this..it keeps combining my stations together something like UUU00452648BBBB….HHHHHZZZZZfffff. I’m looking at the help pages but there are few examples, any suggestions? This is what I’ve written so far:
u=char(files(keep==1));
str1=sprintf(‘for event %s stations passed criteria
test=%fn’,char(dirs(i)),char(u));
disp(str1)
where u=
U02B.HHZf
U04B.HHZf
U05B.HHZf
U06B.HHZf
and dirs(i) corresponds to my directories. Any suggestions or help in what I’m doing wrong?
KayleI’m trying to get sprintf to print out a line that says:
‘for event —– stations pass the criteria test=’
where it will list the results for my stations vertically like:
U02B.HHZf
U04B.HHZf
U05B.HHZf
U06B.HHZf
and so on. I can’t seem to get it to do this..it keeps combining my stations together something like UUU00452648BBBB….HHHHHZZZZZfffff. I’m looking at the help pages but there are few examples, any suggestions? This is what I’ve written so far:
u=char(files(keep==1));
str1=sprintf(‘for event %s stations passed criteria
test=%fn’,char(dirs(i)),char(u));
disp(str1)
where u=
U02B.HHZf
U04B.HHZf
U05B.HHZf
U06B.HHZf
and dirs(i) corresponds to my directories. Any suggestions or help in what I’m doing wrong?
Kayle I’m trying to get sprintf to print out a line that says:
‘for event —– stations pass the criteria test=’
where it will list the results for my stations vertically like:
U02B.HHZf
U04B.HHZf
U05B.HHZf
U06B.HHZf
and so on. I can’t seem to get it to do this..it keeps combining my stations together something like UUU00452648BBBB….HHHHHZZZZZfffff. I’m looking at the help pages but there are few examples, any suggestions? This is what I’ve written so far:
u=char(files(keep==1));
str1=sprintf(‘for event %s stations passed criteria
test=%fn’,char(dirs(i)),char(u));
disp(str1)
where u=
U02B.HHZf
U04B.HHZf
U05B.HHZf
U06B.HHZf
and dirs(i) corresponds to my directories. Any suggestions or help in what I’m doing wrong?
Kayle sprintf MATLAB Answers — New Questions