/r/matlab
Official MATLAB subreddit
MATLAB news, code tips and tricks, questions, and discussion! We are here to help, but won't do your homework or help you pirate software.
The effort you put into asking a question is often matched by the quality of our answers.
Try saturnapi to share and run MATLAB code in a web browser!
If you want flair simply Message the mods
/r/matlab
I have to submit the video resume for the role of an EDG intern. I also have to complete the coding round before that.
All of this I have to complete by Feb 6. Any tips are welcome, esp on resume content and questions. Thank you
I am stimulating the branch line coupler in the first ppt you have given, and I found that while it could stimulate S11 and S31 in different wavelength, I found it could not stimulate S21 and S41 correctly, instead they overlap with S31 and S21 respectively.This is my code:
Z=50;
Z1=Z/sqrt(2);
omega=0:0.01:2;
syms S11 S21 S31 S41;
for i=1:1:201
resOdd=1;
Odd1=[1,0;-1i/Z,1];
Odd2=[cos(pi/2/omega(i)),1i*Z1*sin(pi/2/omega(i));1i*sin(pi/2/omega(i))/Z1,cos(pi/2/omega(i))];
resOdd=resOdd*Odd1*Odd2*Odd1;
AOdd=resOdd(1,1);BOdd=resOdd(1,2);COdd=resOdd(2,1);DOdd=resOdd(2,2);
S11Odd=(-DOdd+AOdd-Z*COdd+BOdd/Z)/(DOdd+AOdd+Z*COdd+BOdd/Z);S21Odd=2*Z/(Z*DOdd+Z*AOdd+Z^2*COdd+BOdd);
resEven=1;Even1=[1,0;1i/Z,1];
Even2=[cos(pi/2/omega(i)),1i*Z1*sin(pi/2/omega(i));1i*sin(pi/2/omega(i))/Z1,cos(pi/2/omega(i))];
resEven=resEven*Even1*Even2*Even1;
AEven=resEven(1,1);BEven=resEven(1,2);CEven=resEven(2,1);DEven=resEven(2,2);
S11Even=(-DEven+AEven-Z*CEven+BEven/Z)/(DEven+AEven+Z*CEven+BEven/Z);S21Even=2*Z/(Z*DEven+Z*AEven+Z^2*CEven+BEven);
S11a=abs((S11Even+S11Odd)/2);
S21a=abs((S21Even+S21Odd)/2);
S31a=abs((S21Even-S21Odd)/2);
S41a=abs((S11Even-S11Odd)/2);
S11(i)=20*log10(S11a);S21(i)=20*log10(S21a);S31(i)=20*log10(S31a);S41(i)=20*log10(S41a);
end
plot(omega,S11)
hold on
plot(omega,S21)
hold on
plot(omega,S31)
hold on
plot(omega,S41)
hold off
P1 is my stimulation result:
and P2&P3 is the stimulation result from other researches of branch line coupler:
I have checked both my code and the scale conversion between frequency and wavelength, from which I still could not understand how the results are not matched.
K1,K2,K3,K4 are known integers.
theta_1 is known
Does anyone know what this function (RefCoeff) does or what parameters it takes? I did look it up but it didn't show up anywhere. I know it has something to do with the reflection coefficient. What are the parameters though?
I'm trying to simulate an Industrial Control unit in Simulink, for a larger project. So, for starters I have tried to create a Conveyer belt (on the right) which is connected to two rollers. There is also a DC motor connected to a 1:1 Gear which connects to a rotational motion sensor, which connects to an Inertia Block.
Now, I'm trying to connect the inertia block to the rollers to make the full circuit and try to run this thing, but I can't.
I don't know if the configuration has mistakes, or am I missing something. If anyone knows anything about it, please leave a comment.
Hello guys!
I'm working on a project which needs to convert time table to MF4. Doing this is the easy part.
I have lots of signals in the time table need to add units. Not sure on how to proceed, I'd appreciate any leads possible.
Thanks.
I was at a supersonic drone club yesterday and the leader was showing the simulation of the drone through simulink and was controlling it using a joystick and then it hit me. Even though it’s not specifically made to be one could simulink be used as a game engine like unity ?
So, I am trying to import this data from excel into matlab, but it is not letting me import the titles for the data. How do I make it import that row? If I turn off the change things to NaN it just makes it where it can't import.
Thank you!
I was working on a project and accidentally clicked on something without noticing and now none of the scopes wanna open no matter how how many times I click on them. I checked all background windows and there’s nothing there. I even tried getting a new scope from the library but even that doesn’t wanna open. Only time scope works. Can someone please help me get it working again?
Ps. I’m a noob to matlab so sorry if this is a common issue. Also I’m using the 2015 version
https://matlab.mathworks.com/open/github/v1?repo=LampYeeter/3d-rotator
It may not work online
I have run multiple simulations of a system and in each run I changed one parameter. I saved the .fig files of a scope I am interested in but the scope plots 2 figures separated by the layout function (so there is one on top and one on the bottom part when you click/view the scope). How can I plot only the top figure (1st input in the scope) from the various .fig files that I saved? I want to highlight the difference when I change a specific parameter (increase and decrease) and repeat for each parameter that I changed.
Thank you a lot in advance!
Hello , I want to transform this code that solves a pde equation with the ode solver into finite diferences, because I want to take the code as a matlab function block in simulink so it stands no ode solver(since it is an iterator take much time every time step so never ends simulation ) thats why i want to take it into finite differences .The equations are the following
The inital code is the following with ode solver:
L = 20 ; % Longitud del lecho (m)
eps = 0.4; % Porosidad
u = 0.2; % Velocidad superficial del fluido (m/s)
k_f = 0.02; % Constante de transferencia de masa (1/s)
c0 = 0;
Kf = 4; % Constante de Freundlich
rhop = 1520;
n = 2; % Exponente de Freundlich
% Concentración inicial del fluido (kg/m³)
q0 = 4.320; % Concentración inicial en el sólido (kg/m³)
% Densidad del adsorbente (kg/m³)
tf = 10; % Tiempo final de simulación (horas)
Nt = 100;
t = linspace(0, tf*3600, Nt);
Nz = 100;
z = linspace(0, L,Nz);
dz = z(2) - z(1);
% Initial conditions
ICA = max(ones(1, Nz) * c0, 1e-12); % Evitar valores negativos o cero
ICB = ones(1, Nz) * q0;
IC = [ICA ICB];
options = odeset('RelTol', 1e-6, 'AbsTol', 1e-8, 'InitialStep', 1e-4, 'MaxStep', 100);
[t, y] = ode15s(@fun_pde, t, IC, options, Nz, eps, n, Kf, k_f, u, rhop, dz);
% Define value
cc = y(:, 1:Nz);
qq = y(:, Nz+1:end);
% Recalculate new limit conditions
cc(:, 1) = 0;
cc(:, end) = cc(:, end-1);
% Plotting
cp = cc(:, end) ./ c0;
qp = qq(:, :) ./ q0;
%q_promedio = mean(qq, 2); % Promedio de q en el lecho para cada instante de tiempo
%conversion = 1 - (q_promedio / q0); % Conversión normalizada
figure;
subplot(2, 1, 1);
time = t / 3600; % Convertir a horas
plot(time, 1- qp, 'b', 'LineWidth', 1.5);
xlabel('Tiempo (horas)');
ylabel('Conversion');
title('Curva de conversión durante la desorción');
grid on;
subplot(2, 1, 2);
plot(t / 3600, (cc(:,:)), 'LineWidth', 1.5);
xlabel('Tiempo (horas)');
ylabel('Soluciòn kg/m3');
title('Curva de carga de la solucion durante la desorciòn');
grid on;
% PDE function
function dydt = fun_pde(~, y, Nz, eps, n, Kf, k_f, u, rhop, dz)
dcdt = zeros(Nz, 1);
dqdt = zeros(Nz, 1);
c = y(1:Nz);
q = y(Nz+1:2*Nz);
% Boundary conditions
c(1) = max(c(1), 0); % Asegurar que c(1) sea no negativo
c(end) = c(end-1); % Asegurar que c(1) sea no negativo
% Interior nodes
qstar = zeros(Nz, 1);
dcdz = zeros(Nz, 1);
for i = 2:Nz-1
qstar(i) = Kf .* max(c(i), 1e-12).^(1/n); % Evitar problemas numéricos
dqdt(i) = k_f .* (qstar(i) - q(i));
% if i < Nz
dcdz(i) = (c(i+1) - c(i-1)) / (2 * dz);
%else
% dcdz(i) = (c(i) - c(i-1)) / dz;
%end
dcdt(i) = -u * dcdz(i) - rhop * ((1 - eps) / eps) .* dqdt(i);
end
dydt = [dcdt; dqdt];
end
next is a try to solve with finite diferences but get someting different:
L = 20 ; % Longitud del lecho (m)
eps = 0.4; % Porosidad
u = 0.2; % Velocidad superficial del fluido (m/s)
k_f = 0.02; % Constante de transferencia de masa (1/s)
c0 = 0; % Concentración inicial del fluido (kg/m³)
Kf = 4; % Constante de Freundlich
rhop = 1520; % Densidad del adsorbente (kg/m³)
n = 2; % Exponente de Freundlich
q0 = 4.320; % Concentración inicial en el sólido (kg/m³)
tf = 10; % Tiempo final de simulación (horas)
Nz = 100; % Número de nodos espaciales
% Discretización espacial y temporal
z = linspace(0, L, Nz);
t = linspace(0, tf*3600, Nt);
dz = z(2) - z(1);
dt = t(2) - t(1); % Paso temporal
% Condiciones iniciales
c = ones(Nt, Nz) * c0; % Concentración en el fluido
q = ones(Nt, Nz) * q0; % Concentración en el sólido
% Iteración en el tiempo (Diferencias Finitas Explícitas)
for ti = 1:Nt-1
for zi = 2:Nz-1
% Isoterma de Freundlich
qstar = Kf * max(c(ti, zi), 1e-12)^(1/n);
% Transferencia de masa (Desorción)
dqdt = k_f * (qstar - q(ti, zi));
% Gradiente espacial de concentración (Diferencias centradas)
dcdz = (c(ti, zi+1) - c(ti, zi-1)) / (2 * dz);
% Ecuación de balance de masa en el fluido
dcdt = -u * dcdz - rhop * ((1 - eps) / eps) * dqdt;
% Actualizar valores asegurando que sean positivos
c(ti+1, zi) = max(c(ti, zi) + dcdt * dt, 0);
q(ti+1, zi) = max(q(ti, zi) + dqdt * dt, 0);
end
end
% Condiciones de frontera
c(:, 1) = c0; % Entrada con concentración baja
c(:, Nz) = c(:, Nz-1); % Gradiente nulo en la salida
% Cálculo de la conversión normalizada
qp = q(:, :) ./ q0;
% Graficar resultados
figure;
subplot(2, 1, 1);
plot(t / 3600, 1-qp, 'b', 'LineWidth', 1.5);
xlabel('Tiempo (horas)');
ylabel('Conversion');
title('Curva de conversión durante la desorción');
grid on;
subplot(2, 1, 2);
c_salida = c(:, :); % Concentración en la salida del lecho
plot(t / 3600, c_salida, 'r', 'LineWidth', 1.5);
xlabel('Tiempo (horas)');
ylabel('Soluciòn kg/m3');
title('Curva de carga de la solucion durante la desorciòn');
grid on;
I dont know where is wrong .Thanks in advance
clear, clc, close all
t = [-3.14:0.025:3.14];
x = [sin(pi*t)];
y = [1.5cos(pit)];
i = 0.9;
a = 0.05;
while i > 0
t = [-3.14:a:3.14];
x = [x,isin(pit)];
y = [y,1.5icos(pi*t)];
i = i - 0.1;
a = (i^-1)*.05;
end
z = 0.5*((x.^2) - (0.5*(y.^2)));
s = 0;
d = 5;
f = 5;
while s < 10000
yrot = (ycos(pi/270)) + (zsin(pi/270));
zrot = -(ysin(pi/270)) + (zcos(pi/270));
y = yrot;
z = zrot;
xrot = (xcos(pi/180)) - (ysin(pi/180));
yrot = (xsin(pi/180)) + (ycos(pi/180));
x = xrot;
y = yrot;
xproj = x.*(f./(y+d));
zproj = z.*(f./(y+d));
plot(xproj,zproj,'.')
xlim([-2,2])
ylim([-1.6,1.6])
title('haha pringle go brrr')
s = s + 1;
drawnow
end
Is there a way to create a fatter version of a sine wave? Close to a square wave but still rounded on the edges.
Here's the unfattened sine wave I'm using. . .
t = linspace(0, 1, 8400); % Time vector from 0 to 1 second
yy1 = sin(2*pi*8*t); % Sine wave function
Hi everyone! Which GPU Brand do you recommend for me? I'll be working on deep learning with Images in MATLAB, and currently, my GPU is NVIDIA GeForce GTX 1050 TI. I'm considering upgrading to Palit NVIDIA GeForce RTX 3060 DUAL 12GB GDDR6 192-bit DP+HDMI since it has 12GB of VRAM and a 192-bit interface.
Please let me know what is best for price and performance. I have included some details about my workstation. Thank you.
Processor: AMD Ryzen 5 3600 6-Core Processor 3.60 GHz
RAM: 32 GB Corsair
System Type: 64-bit operating system, x64-based processor
Windows: Microsoft Windows|
GPU: NVIDIA GeForce GTX 1050 TI
OS: Windows 11
SDD: Kingston 500 GB (NVMe)
HDD 1: Toshiba 1 TB (S-ATA Gen 3, 6 Gbps)
HDD 2: Seagate 2 TB (S-ATA Gen 3, 6 Gbps)
Hello,
I am very new to Matlab and my instructor was not sure how to fix my problem. I'm trying to simulate an AC circuit that contains a current dependent voltage source. I'm using a current meter to get the value of the current in question and then I'm using a gain block to multiply that current by 39. The dependent source should have a voltage equal to 39*I_x , where I_x is the current. Normally this works fine, but this time, having the gain be higher than 30 causes a problem. I'm not sure precisely what the error code is trying to tell me other than the fact that it has highlight my current meter as a problem.
I'd really appreciate it if someone more knowledgeable than me could look at the screenshot and file.
Link to Dropbox for the .slx file (Hopefully this is okay) - Link
Thank you
EDIT - It may be Simulink and not Simscape. Apologies if I'm wrong.
Hello, I want to model a desorption reactor with a fixed bed containing gold-laden carbon, through which a desorbing solution passes, which extracts extra gold. I am trying to solve it using a PDE system in which I create multiple nodes, assimilating it as if it were solved using the finite difference method. Using a forward difference for the initial node, a central difference for the intermediate nodes, and a backward difference for the final node. These are relative to a distance differential.The equations are as follows.
So i tried finite differences for dc/dz with forward difference for eactor entry , central along the reactor , and backward in the exit, and dc/dt and dq/dt use integrator blocks, I consider Co= 0 kg/m3 solution and q0=4.320 kg/m3 carbon. Just considering 5 nodes , shall be more but first i want to make the first five work fine .
And each node consist on the following layout , where can be seen a time integral block term for q(carbon loading) and c(solution loading , it shows also a length step and inputs from the forwarded and current node soluction concentration(in the case of the first node)
My problem is that I am getting the same values on each node, which I don't know if it is right the layout approach, since they should be different with relation to time and besides when i increase or decrease the input stream speed , the values in carbon and solution loading not change at all. thanks in advance
File is attached in the link : https://riveril123.quickconnect.to/d/s/11wyBkc59ZycO0kl7OwWITAm221uWy5e/hgq22s1F0Ty03_NsErAwiuc3kyxewhUM-urqAt1qkAww
Hello,
I am currently studying the gps standard and the user position calculation I would like to know if there is a way to generate a gpsL1 navigation message that contains auto sets all the different values to correspond to a specific satellite in a certain time and date In the website https://in-the-sky.org/satmap_worldmap.php?gps=1 it is actually possible to check for satellites' positions and parameters at some given date What i am needing is a way to input into the MATLAB navigation message generator, time date and number of satellite, so it automatically sets all parameters which are contained inside the navigation message, such as clockdrift, seminajor, perigee, etc, so i can then extract those values and validate my position calculations
To clarify, I've already created custom lnav messages, but with known navigation message parameters
I have a project where I need to build a GUI application in MATLAB using AppDesigner. I've done everything up to a certain point where the requirement asks me to display the values (breaks, coefs, l, k, d) obtained when calling the function.
These are the requirements.
Study the functions mkpp, unmkpp, ppval and create a GUI application in MATLAB using AppDesigner for the following syntaxes:
pp = mkpp(breaks, coefs)
[breaks, coefs, l, k, d] = unmkpp(pp)
v = ppval(pp, xq)
The graphical user interface should contain the following elements:
4 editable text boxes to input the arguments: breaks
, coefs
, pp
, xq
. The xq
input argument should be initialized with linspace(breaks(1), breaks(end), 1000);
5 read-only text boxes to display the values of breaks
, coefs
, l
, k
, and d
obtained from calling the function unmkpp
.
A "Plot" button, which when activated opens a new window created with AppDesigner containing a graphical object of type axes
for displaying the graph using the ppval
function.
Could anyone please help?
And that's my code:
classdef proiect < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
xqEditField matlab.ui.control.EditField
xqEditFieldLabel matlab.ui.control.Label
ppEditField matlab.ui.control.EditField
ppEditFieldLabel matlab.ui.control.Label
coefsEditField matlab.ui.control.EditField
coefsEditFieldLabel matlab.ui.control.Label
breaksEditField matlab.ui.control.EditField
breaksEditFieldLabel matlab.ui.control.Label
DesenareButton matlab.ui.control.Button
dOutputEditField matlab.ui.control.NumericEditField
dOutputEditFieldLabel matlab.ui.control.Label
kOutputEditField matlab.ui.control.NumericEditField
kOutputEditFieldLabel matlab.ui.control.Label
lOutputEditField matlab.ui.control.NumericEditField
lOutputEditFieldLabel matlab.ui.control.Label
coefsOutputEditField matlab.ui.control.NumericEditField
coefsOutputEditFieldLabel matlab.ui.control.Label
breaksOutpEditField matlab.ui.control.NumericEditField
breaksOutpEditFieldLabel matlab.ui.control.Label
UIAxes matlab.ui.control.UIAxes
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: DesenareButton
function DesenareButtonPushed(app, event)
inputBreaks = app.breaksEditField.Value;
inputCoefs = app.coefsEditField.Value;
breaks = str2num(inputBreaks); % Convert string to numeric
coefs = str2num(inputCoefs);
try
pp = mkpp(breaks, coefs);
catch ME
uialert(app.UIFigure, ['Eroare la crearea spline-ului: ', ME.message], 'Eroare', 'Icon', 'error');
return;
end
app.breaksOutpEditField.Value = join(string(breaks), ' '); % Vector breaks ca șir
app.coefsOutputEditField.Value = join(string(coefs(:)'), '; '); % Vector coeficienti transformat în șir
app.ppEditField.Value = 'Spline definit!'; % Sau un mesaj personalizat
xq = linspace(breaks(1), breaks(end), 1000); % Punctele de interpolare
yq = ppval(pp, xq); % Calculul valorilor spline-ului
plot(app.UIAxes, xq, yq, 'LineWidth', 2);
title(app.UIAxes, 'Graficul Spline-ului');
xlabel(app.UIAxes, 'X');
ylabel(app.UIAxes, 'Y');
end
end
methods (Access = private)
function createComponents(app)
% Create UIFigure and hide until all components are created
app.UIFigure = uifigure('Visible', 'off');
app.UIFigure.Color = [0.8745 0.9294 0.5569];
app.UIFigure.Position = [100 100 640 480];
= 'MATLAB App';
% Create UIAxes
app.UIAxes = uiaxes(app.UIFigure);
title(app.UIAxes, 'Title')
xlabel(app.UIAxes, 'X')
ylabel(app.UIAxes, 'Y')
zlabel(app.UIAxes, 'Z')
app.UIAxes.Position = [333 217 295 255];
% Create breaksOutpEditFieldLabel
app.breaksOutpEditFieldLabel = uilabel(app.UIFigure);
app.breaksOutpEditFieldLabel.HorizontalAlignment = 'right';
app.breaksOutpEditFieldLabel.Position = [23 217 74 22];
app.breaksOutpEditFieldLabel.Text = 'breaks Outp';
% Create breaksOutpEditField
app.breaksOutpEditField = uieditfield(app.UIFigure, 'numeric');
app.breaksOutpEditField.Editable = 'off';
app.breaksOutpEditField.Position = [112 217 100 22];
% Create coefsOutputEditFieldLabel
app.coefsOutputEditFieldLabel = uilabel(app.UIFigure);
app.coefsOutputEditFieldLabel.HorizontalAlignment = 'right';
app.coefsOutputEditFieldLabel.Position = [25 172 73 22];
app.coefsOutputEditFieldLabel.Text = 'coefs Output';
% Create coefsOutputEditField
app.coefsOutputEditField = uieditfield(app.UIFigure, 'numeric');
app.coefsOutputEditField.Editable = 'off';
app.coefsOutputEditField.Position = [113 172 100 22];
% Create lOutputEditFieldLabel
app.lOutputEditFieldLabel = uilabel(app.UIFigure);
app.lOutputEditFieldLabel.HorizontalAlignment = 'right';
app.lOutputEditFieldLabel.Position = [51 123 47 22];
app.lOutputEditFieldLabel.Text = 'l Output';
% Create lOutputEditField
app.lOutputEditField = uieditfield(app.UIFigure, 'numeric');
app.lOutputEditField.Editable = 'off';
app.lOutputEditField.Position = [113 123 100 22];
% Create kOutputEditFieldLabel
app.kOutputEditFieldLabel = uilabel(app.UIFigure);
app.kOutputEditFieldLabel.HorizontalAlignment = 'right';
app.kOutputEditFieldLabel.Position = [49 74 50 22];
app.kOutputEditFieldLabel.Text = 'k Output';
% Create kOutputEditField
app.kOutputEditField = uieditfield(app.UIFigure, 'numeric');
app.kOutputEditField.Editable = 'off';
app.kOutputEditField.Position = [114 74 100 22];
% Create dOutputEditFieldLabel
app.dOutputEditFieldLabel = uilabel(app.UIFigure);
app.dOutputEditFieldLabel.HorizontalAlignment = 'right';
app.dOutputEditFieldLabel.Position = [49 22 51 22];
app.dOutputEditFieldLabel.Text = 'd Output';
% Create dOutputEditField
app.dOutputEditField = uieditfield(app.UIFigure, 'numeric');
app.dOutputEditField.Editable = 'off';
app.dOutputEditField.Position = [115 22 100 22];
% Create DesenareButton
app.DesenareButton = uibutton(app.UIFigure, 'push');
app.DesenareButton.ButtonPushedFcn = createCallbackFcn(app, u/DesenareButtonPushed, true);
app.DesenareButton.Position = [526 22 94 78];
app.DesenareButton.Text = 'Desenare';
% Create breaksEditFieldLabel
app.breaksEditFieldLabel = uilabel(app.UIFigure);
app.breaksEditFieldLabel.HorizontalAlignment = 'right';
app.breaksEditFieldLabel.Position = [26 446 41 22];
app.breaksEditFieldLabel.Text = 'breaks';
% Create breaksEditField
app.breaksEditField = uieditfield(app.UIFigure, 'text');
app.breaksEditField.Position = [82 446 130 22];
% Create coefsEditFieldLabel
app.coefsEditFieldLabel = uilabel(app.UIFigure);
app.coefsEditFieldLabel.HorizontalAlignment = 'right';
app.coefsEditFieldLabel.Position = [26 408 34 22];
app.coefsEditFieldLabel.Text = 'coefs';
% Create coefsEditField
app.coefsEditField = uieditfield(app.UIFigure, 'text');
app.coefsEditField.Position = [75 408 241 22];
% Show the figure after all components are created
app.UIFigure.Visible = 'on';
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = proiect
createComponents(app);
registerApp(app, app.UIFigure);
if nargout == 0
clear app;
end
end
% Code that executes before app deletion
function delete(app)
delete(app.UIFigure);
end
end
end
app.UIFigure.Name
message.txt8 KB
I am looking for a tool or Simulink project that is already complete where I can enter my motor parameters (and possibly inverter) and do some testing with PID tuning in the case of Field Oriented Control.
I found this: https://it.mathworks.com/help/mcb/gs/tune-pi-controllers-using-foc-autotuner.html?s_eid=PSM_15028 but I don't understand if I can use it only via software without having to buy that motor and inveter.
Again, I am interested in doing PID tuning tests for my motor in the case of FOC, I don't want the simulink to generate embedded code for Texas Instruments etc.
There is a lot of Simulink material online, so I ask for your help since I have little experience with Matlab
Thank you.
I'm working on a project right now that recquires ~500 lines of data entry into a matrix, all by hand because I'm a normal person who can be trusted with free time. I'm about halfway through, but there's an issue-- every 50 cells or so, Matlab will randomly double the first digit of the cell (so 350 becomes 3350, 10 becomes 110, etc). I can't figure out what's causing it- I'm not holding down the button too long, matlab doesn't code a button hold as multiple presses afaik- and there's no other reason i can think it'd do this. I usually catch and fix the error but I've missed a few of them and I worry it'll affect my code's results. Any ideas as to what's causing this?
Hello all, I am recreating the tests which were done by vector cast previously in polyspace test now. I have some issues regarding parsing code. The function preprocessor definition is not identified. This project is built for tasking compiler but could execute unit tests in vector cast using mingw previously, I am not sure why polyspace test requires so many includes. May I please know how to declare function preprocessor definition in Preprocessor definitions tab in configuration or the code should be changed ?
Thanks in advance
Hello , I need to develop a curve envelope from multiple curves like the shades Portion in fig. But I have no knowledge in matlab. Matlab is not required much in my study so please can anyone provide me resources to develop such envelope?
Ps; main objective is to develop curve envelope. Thank you. You can drop code too.
SOLVED, SEE MY REPLY
So I know that it's not recommended to use nested for loops for this purpose, but my school assignment requires we use nested for loops.
Anyways, when I execute this code, it just doesn't stop running, and I'm not experienced enough to understand why that is. It doesn't finish, so I don't get any errors or warnings to help me find a problem. Could you guys help me out here?
Two previous sections of code run just fine, it's just this block that is giving me trouble:
%Copy Task 1 initialization block here:
%initialization
clc; clear; close
all;maxDays = 40;
cb = zeros(maxDays,1);
lm = zeros(maxDays,1);
cb(1) = 20;
lm (1) = 20;
cb2lm_prob = 0.642784;
%prob that a bike will go from CB to LM in a day
lm2cb_prob = 0.274267;
%prob that a bike will go from LM to CB in a day
for i = 1:maxDays-1
%initialize # of bikes moving from lm to cb in a day
lm2cb = 0;
%check if this bike has moved
for b = 1:lm(i)
if rand <= lm2cb_prob
lm2cb = lm2cb+1;
end
end
%initialize # of bikes moving from cb to lm in a day
cb2lm = 0;
%check if this bike has moved
for b = 1:cb(i)
if rand <= cb2lm_prob
cb2lm = cb2lm + 1;
end
end
%adjust totals of lm and cb
lm(i+1) = lm(i) + lm2cb - cb2lm;
cb(i+1) = cb(i) + cb2lm - lm2cb;
end