Tag Archives: matlab
How to set unit properties for arrays in simulink?
I have 3×1 positionArray such as [latitude, longitude, altitude] and units are [rad,rad,m].
This array is in the input for simulink. Is there any way to define different units for array in simulink?
In the "Signal Attributes" section, i tried:
rad, rad, m
rad_rad_m
[rad,rad,m]
{rad,rad,m}
nothing works.
Unit specifications are explained in following link, but there is no information about array units.
https://www.mathworks.com/help/simulink/ug/units-in-simulink.htmlI have 3×1 positionArray such as [latitude, longitude, altitude] and units are [rad,rad,m].
This array is in the input for simulink. Is there any way to define different units for array in simulink?
In the "Signal Attributes" section, i tried:
rad, rad, m
rad_rad_m
[rad,rad,m]
{rad,rad,m}
nothing works.
Unit specifications are explained in following link, but there is no information about array units.
https://www.mathworks.com/help/simulink/ug/units-in-simulink.html I have 3×1 positionArray such as [latitude, longitude, altitude] and units are [rad,rad,m].
This array is in the input for simulink. Is there any way to define different units for array in simulink?
In the "Signal Attributes" section, i tried:
rad, rad, m
rad_rad_m
[rad,rad,m]
{rad,rad,m}
nothing works.
Unit specifications are explained in following link, but there is no information about array units.
https://www.mathworks.com/help/simulink/ug/units-in-simulink.html signal attributes, unit, array MATLAB Answers — New Questions
how to implement lifi communication in matlab?
how to implement lifi communication in matlab?how to implement lifi communication in matlab? how to implement lifi communication in matlab? lifi-matlab MATLAB Answers — New Questions
how to simulate lifi transmitter and reciever using simulink
i need to simulate lifi technology transmitter and reciever using matlab simulink….also need help to use led block in simulink….i have the led block that has terminals as anode and cathode…..need led block as having only input and output terminals as they are the final block of my transmitter section.i need to simulate lifi technology transmitter and reciever using matlab simulink….also need help to use led block in simulink….i have the led block that has terminals as anode and cathode…..need led block as having only input and output terminals as they are the final block of my transmitter section. i need to simulate lifi technology transmitter and reciever using matlab simulink….also need help to use led block in simulink….i have the led block that has terminals as anode and cathode…..need led block as having only input and output terminals as they are the final block of my transmitter section. lifi, simulink, led, visible light communication, transmitter, reciever, simulation MATLAB Answers — New Questions
ODBC interface for changing login way
Hi, is there a way before I pack a GUI to an exe file to make an interface for later changing the connection ODBC to SQL server after that in case that server IP is changed meanwhile? Or I must to recode the source code and pack again? Thanks! R2015aHi, is there a way before I pack a GUI to an exe file to make an interface for later changing the connection ODBC to SQL server after that in case that server IP is changed meanwhile? Or I must to recode the source code and pack again? Thanks! R2015a Hi, is there a way before I pack a GUI to an exe file to make an interface for later changing the connection ODBC to SQL server after that in case that server IP is changed meanwhile? Or I must to recode the source code and pack again? Thanks! R2015a sql, connection, interface MATLAB Answers — New Questions
how can i fix this export error in Roadrunner?
1 month ago, I already export this data in RoadRunner.
and today I tried to export same data. but it was not working.
So how can I fix this error?1 month ago, I already export this data in RoadRunner.
and today I tried to export same data. but it was not working.
So how can I fix this error? 1 month ago, I already export this data in RoadRunner.
and today I tried to export same data. but it was not working.
So how can I fix this error? export, roadrunner MATLAB Answers — New Questions
How to highlight a area in figure
I want to hightlight the defect in croppedImage.mat by convHull.mat.
It’s better set transparent.
the size of two figures is same.I want to hightlight the defect in croppedImage.mat by convHull.mat.
It’s better set transparent.
the size of two figures is same. I want to hightlight the defect in croppedImage.mat by convHull.mat.
It’s better set transparent.
the size of two figures is same. highlight area MATLAB Answers — New Questions
Apply ‘rotatefactors’ on the observations to represent them in the new factorial design (PCA)
Hi all,
I guess, that it is an easy issue, but I can not figure out how to apply rotatefactors on the SCORES matrix resulting from a previous PCA:
(1) I run a PCA following:
[wcoeff,score] = pca(zscore(DataSet))
(2) I would like to rotate my principal components using rotatefactors:
[NewCoeff,TransfMatrix] = rotatefactors(wcoeff);
NewCoeff should give the new coordinates of the variables on the varimax-rotated components.
My question is: How can I compute the coordinates ‘NewScores’ of my observations on the new components? My idea is to plot them on a biplot and on an other scatter-plot where each axis is a component.
I guess that there is something easy like:
NewScores = score * TransfMatrix
Am I right?
RomainHi all,
I guess, that it is an easy issue, but I can not figure out how to apply rotatefactors on the SCORES matrix resulting from a previous PCA:
(1) I run a PCA following:
[wcoeff,score] = pca(zscore(DataSet))
(2) I would like to rotate my principal components using rotatefactors:
[NewCoeff,TransfMatrix] = rotatefactors(wcoeff);
NewCoeff should give the new coordinates of the variables on the varimax-rotated components.
My question is: How can I compute the coordinates ‘NewScores’ of my observations on the new components? My idea is to plot them on a biplot and on an other scatter-plot where each axis is a component.
I guess that there is something easy like:
NewScores = score * TransfMatrix
Am I right?
Romain Hi all,
I guess, that it is an easy issue, but I can not figure out how to apply rotatefactors on the SCORES matrix resulting from a previous PCA:
(1) I run a PCA following:
[wcoeff,score] = pca(zscore(DataSet))
(2) I would like to rotate my principal components using rotatefactors:
[NewCoeff,TransfMatrix] = rotatefactors(wcoeff);
NewCoeff should give the new coordinates of the variables on the varimax-rotated components.
My question is: How can I compute the coordinates ‘NewScores’ of my observations on the new components? My idea is to plot them on a biplot and on an other scatter-plot where each axis is a component.
I guess that there is something easy like:
NewScores = score * TransfMatrix
Am I right?
Romain pca, rotatefactors, scores MATLAB Answers — New Questions
Minimize the results in regression model
In my regression model I have four(04) input varibales (Al2O3, TiO2, Pressure, Speed) and there are one responce (Surface roughness(Ra)), So I don’t have idea how find optimum vales for four control factors to minimze the Surface roughness.
To develop this model I have done 16 experiments and the predicted values are shon below
Ra
0.064
0.039
0.071
0.238
3.256
3.910
2.786
0.037
3.604
0.043
0.037
0.060
0.049
0.023
0.061
1.113
Developed Regession Model
Ra = 28.66 + 50.01 Al2O3 + 35.80 TiO2 – 6.925 Pressure – 0.4221 Speed – 182.6 Al2O3*Al2O3 – 3.741 TiO2*TiO2 + 0.7566 Pressure*Pressure + 0.001753 Speed*Speed + 8.210 Al2O3*TiO2 – 2.541 Al2O3*Pressure – 0.04987 Al2O3*Speed – 3.373 TiO2*Pressure – 0.2407 TiO2*Speed + 0.03294 Pressure*Speed + 179.8 Al2O3*Al2O3*Al2O3
Can anyone help me to develop the Maltlab code to solve this problem ? thanks for your valuble time spend on thisIn my regression model I have four(04) input varibales (Al2O3, TiO2, Pressure, Speed) and there are one responce (Surface roughness(Ra)), So I don’t have idea how find optimum vales for four control factors to minimze the Surface roughness.
To develop this model I have done 16 experiments and the predicted values are shon below
Ra
0.064
0.039
0.071
0.238
3.256
3.910
2.786
0.037
3.604
0.043
0.037
0.060
0.049
0.023
0.061
1.113
Developed Regession Model
Ra = 28.66 + 50.01 Al2O3 + 35.80 TiO2 – 6.925 Pressure – 0.4221 Speed – 182.6 Al2O3*Al2O3 – 3.741 TiO2*TiO2 + 0.7566 Pressure*Pressure + 0.001753 Speed*Speed + 8.210 Al2O3*TiO2 – 2.541 Al2O3*Pressure – 0.04987 Al2O3*Speed – 3.373 TiO2*Pressure – 0.2407 TiO2*Speed + 0.03294 Pressure*Speed + 179.8 Al2O3*Al2O3*Al2O3
Can anyone help me to develop the Maltlab code to solve this problem ? thanks for your valuble time spend on this In my regression model I have four(04) input varibales (Al2O3, TiO2, Pressure, Speed) and there are one responce (Surface roughness(Ra)), So I don’t have idea how find optimum vales for four control factors to minimze the Surface roughness.
To develop this model I have done 16 experiments and the predicted values are shon below
Ra
0.064
0.039
0.071
0.238
3.256
3.910
2.786
0.037
3.604
0.043
0.037
0.060
0.049
0.023
0.061
1.113
Developed Regession Model
Ra = 28.66 + 50.01 Al2O3 + 35.80 TiO2 – 6.925 Pressure – 0.4221 Speed – 182.6 Al2O3*Al2O3 – 3.741 TiO2*TiO2 + 0.7566 Pressure*Pressure + 0.001753 Speed*Speed + 8.210 Al2O3*TiO2 – 2.541 Al2O3*Pressure – 0.04987 Al2O3*Speed – 3.373 TiO2*Pressure – 0.2407 TiO2*Speed + 0.03294 Pressure*Speed + 179.8 Al2O3*Al2O3*Al2O3
Can anyone help me to develop the Maltlab code to solve this problem ? thanks for your valuble time spend on this fmincon, optimization MATLAB Answers — New Questions
Single Patch antenna design (not using antenna tool box)
I want to design a single patch antenna (rectangle) and I want to output the beam pattern, S11, as a graph. Is there an expert who can make it S-band resonant frequency 3GHz??
For your information, I can’t use an antenna toolI want to design a single patch antenna (rectangle) and I want to output the beam pattern, S11, as a graph. Is there an expert who can make it S-band resonant frequency 3GHz??
For your information, I can’t use an antenna tool I want to design a single patch antenna (rectangle) and I want to output the beam pattern, S11, as a graph. Is there an expert who can make it S-band resonant frequency 3GHz??
For your information, I can’t use an antenna tool antenna, patch antenna MATLAB Answers — New Questions
Volume of irregular shape
I have for example X,Y,Z coordinates of 8 points which form an irregular shape. How can I calculate the volume with in this shape? Eg. coordinates area:
0 0 384,67
0 26,6 385,25
-47,85 26,6 385,9
-47,85 0 385,3
0 0 387,32
0 26,6 387,32
-47,85 26,6 387,32
-47,85 0 387,32I have for example X,Y,Z coordinates of 8 points which form an irregular shape. How can I calculate the volume with in this shape? Eg. coordinates area:
0 0 384,67
0 26,6 385,25
-47,85 26,6 385,9
-47,85 0 385,3
0 0 387,32
0 26,6 387,32
-47,85 26,6 387,32
-47,85 0 387,32 I have for example X,Y,Z coordinates of 8 points which form an irregular shape. How can I calculate the volume with in this shape? Eg. coordinates area:
0 0 384,67
0 26,6 385,25
-47,85 26,6 385,9
-47,85 0 385,3
0 0 387,32
0 26,6 387,32
-47,85 26,6 387,32
-47,85 0 387,32 voleme, convexhul MATLAB Answers — New Questions
Area of the hysteresis loops
Hi Community,
I have a stress vs. strain plot with approximately 30 different loops, and I need to calculate the area enclosed by each loop. I’ve attached a file containing the stress vs. strain data.
Any help or guidance would be greatly appreciated!
Thank you!Hi Community,
I have a stress vs. strain plot with approximately 30 different loops, and I need to calculate the area enclosed by each loop. I’ve attached a file containing the stress vs. strain data.
Any help or guidance would be greatly appreciated!
Thank you! Hi Community,
I have a stress vs. strain plot with approximately 30 different loops, and I need to calculate the area enclosed by each loop. I’ve attached a file containing the stress vs. strain data.
Any help or guidance would be greatly appreciated!
Thank you! matlab MATLAB Answers — New Questions
Can I implement a reflection wave behavior of a microstrip line in Simulink
Hi,I found a microstrip model in the RF Blockset section, but when I placed it in the circuit and ran the simulation, the oscilloscope did not capture any reflection waves(like ADS). Is it because I didn’t set it up correctly, or is this system just unable to simulate reflection waves?Thanks!Hi,I found a microstrip model in the RF Blockset section, but when I placed it in the circuit and ran the simulation, the oscilloscope did not capture any reflection waves(like ADS). Is it because I didn’t set it up correctly, or is this system just unable to simulate reflection waves?Thanks! Hi,I found a microstrip model in the RF Blockset section, but when I placed it in the circuit and ran the simulation, the oscilloscope did not capture any reflection waves(like ADS). Is it because I didn’t set it up correctly, or is this system just unable to simulate reflection waves?Thanks! microstrip line, reflection MATLAB Answers — New Questions
Even after following MISRA Guidelines and Model adviser ran with zero errors POLYSPACE is throwing MISRA C 2012 violations
Post Content Post Content misra c 2012 violation MATLAB Answers — New Questions
How to remove ‘zeros 0’ from histogram so it will not affect imhistmatchn?
Due to the mask, the histogram contains zeros, which is incorrect. How can I remove the zeros from the histogram, or how can I adjust the histogram function to exclude the zeros? This would ensure that the result will not affect the result of the imhistmatch function.
Thank you.Due to the mask, the histogram contains zeros, which is incorrect. How can I remove the zeros from the histogram, or how can I adjust the histogram function to exclude the zeros? This would ensure that the result will not affect the result of the imhistmatch function.
Thank you. Due to the mask, the histogram contains zeros, which is incorrect. How can I remove the zeros from the histogram, or how can I adjust the histogram function to exclude the zeros? This would ensure that the result will not affect the result of the imhistmatch function.
Thank you. histogram, imhistmatchn, matlab, zeros MATLAB Answers — New Questions
Why parameterized MOSFETs does not show response
Hey,
I have an EV model where velocity is controlled via PMSM FOC blockset and when using ideal converter, the model is correctly following the reference speed and generating torque as expected and even when I put MOSFET (Ideal Switching), the model response is as expected, however, when I parameterized the same MOSFETs using preparameterized MOSFET or even I do the parameterizaton on my own using N-Channel MOSFET using datasheet, the response is 0.
I have done the tuning via trial and error and even tried to change the gains to see even some response.
I am attaching the Model here, any expert in this modelling can have look and guide on the issue.Hey,
I have an EV model where velocity is controlled via PMSM FOC blockset and when using ideal converter, the model is correctly following the reference speed and generating torque as expected and even when I put MOSFET (Ideal Switching), the model response is as expected, however, when I parameterized the same MOSFETs using preparameterized MOSFET or even I do the parameterizaton on my own using N-Channel MOSFET using datasheet, the response is 0.
I have done the tuning via trial and error and even tried to change the gains to see even some response.
I am attaching the Model here, any expert in this modelling can have look and guide on the issue. Hey,
I have an EV model where velocity is controlled via PMSM FOC blockset and when using ideal converter, the model is correctly following the reference speed and generating torque as expected and even when I put MOSFET (Ideal Switching), the model response is as expected, however, when I parameterized the same MOSFETs using preparameterized MOSFET or even I do the parameterizaton on my own using N-Channel MOSFET using datasheet, the response is 0.
I have done the tuning via trial and error and even tried to change the gains to see even some response.
I am attaching the Model here, any expert in this modelling can have look and guide on the issue. simscape, power_electronics_control MATLAB Answers — New Questions
Ideas on generalizing the syntax used for constructing complex variables
I am looking for ideas on how to construct a class that generalizes the interface Matlab uses for creating and manipulating complex variables. The general idea is that one could construct a "pets" object by simplying typing:
mypets = 2dogs + 3cats
which would create an object of the pets class.
I can think of a few clunky ways to do this, such as having the constructor parse a string like this:
mypets = pets(‘2dogs + 3cats’).
Another slightly nicer way would be to leave out the parenthesis like this:
pets 2dogs + 3cats
but this still requires an explicit constructor reference. Any ideas anyone?I am looking for ideas on how to construct a class that generalizes the interface Matlab uses for creating and manipulating complex variables. The general idea is that one could construct a "pets" object by simplying typing:
mypets = 2dogs + 3cats
which would create an object of the pets class.
I can think of a few clunky ways to do this, such as having the constructor parse a string like this:
mypets = pets(‘2dogs + 3cats’).
Another slightly nicer way would be to leave out the parenthesis like this:
pets 2dogs + 3cats
but this still requires an explicit constructor reference. Any ideas anyone? I am looking for ideas on how to construct a class that generalizes the interface Matlab uses for creating and manipulating complex variables. The general idea is that one could construct a "pets" object by simplying typing:
mypets = 2dogs + 3cats
which would create an object of the pets class.
I can think of a few clunky ways to do this, such as having the constructor parse a string like this:
mypets = pets(‘2dogs + 3cats’).
Another slightly nicer way would be to leave out the parenthesis like this:
pets 2dogs + 3cats
but this still requires an explicit constructor reference. Any ideas anyone? generalize complex MATLAB Answers — New Questions
Satellite basemap attribution block too large
I am trying to use readBasemapImage to read satellite imagery. However, the image I get has an enormous attribution block, most of which appears to be empty space instead of attribution. Is there a way to read the basemap so that block is an appropriate size, without increasing the zoom level (for better performance panning around the image)? For some reason, if I use "Run with R2024a" in the question editor, it works fine, but doesn’t on my personal computer or laptop (image attached)?
[img, rast, attrib] = readBasemapImage("satellite", [38.7 39.1], [-77.5 -76.9], 14);
mapshow(img, rast);I am trying to use readBasemapImage to read satellite imagery. However, the image I get has an enormous attribution block, most of which appears to be empty space instead of attribution. Is there a way to read the basemap so that block is an appropriate size, without increasing the zoom level (for better performance panning around the image)? For some reason, if I use "Run with R2024a" in the question editor, it works fine, but doesn’t on my personal computer or laptop (image attached)?
[img, rast, attrib] = readBasemapImage("satellite", [38.7 39.1], [-77.5 -76.9], 14);
mapshow(img, rast); I am trying to use readBasemapImage to read satellite imagery. However, the image I get has an enormous attribution block, most of which appears to be empty space instead of attribution. Is there a way to read the basemap so that block is an appropriate size, without increasing the zoom level (for better performance panning around the image)? For some reason, if I use "Run with R2024a" in the question editor, it works fine, but doesn’t on my personal computer or laptop (image attached)?
[img, rast, attrib] = readBasemapImage("satellite", [38.7 39.1], [-77.5 -76.9], 14);
mapshow(img, rast); image MATLAB Answers — New Questions
Figures saved with MATLAB New Desktop cannot be opened in MATLAB Online or on the local computer with MATLAB Old Desktop
Hello,
I have some figures that I saved in MATLAB R2024b with New Desktop on my work computer. When I try to open the figure on my home computer using MATLAB R2024b with Old Desktop, it freezes at FigureController.m at the sendACT function. The exact same thing happens with MATLAB Online too. It freezes at the exact same point. However, if I switch to New Desktop on my local computer, I can see the figures again. The figures are not big at all, they are 100kB maximum.
Is there a solution to this?Hello,
I have some figures that I saved in MATLAB R2024b with New Desktop on my work computer. When I try to open the figure on my home computer using MATLAB R2024b with Old Desktop, it freezes at FigureController.m at the sendACT function. The exact same thing happens with MATLAB Online too. It freezes at the exact same point. However, if I switch to New Desktop on my local computer, I can see the figures again. The figures are not big at all, they are 100kB maximum.
Is there a solution to this? Hello,
I have some figures that I saved in MATLAB R2024b with New Desktop on my work computer. When I try to open the figure on my home computer using MATLAB R2024b with Old Desktop, it freezes at FigureController.m at the sendACT function. The exact same thing happens with MATLAB Online too. It freezes at the exact same point. However, if I switch to New Desktop on my local computer, I can see the figures again. The figures are not big at all, they are 100kB maximum.
Is there a solution to this? matlab, figure, matlab gui MATLAB Answers — New Questions
Custom loss function (based on error multiplication rather than sum) in classification neural network
Hi everyone,
First, thank you! This is a fantastic community from which I’m learning so much. This is my first question (hopefully, I’ll be able to contribute answers in the future!).
I have a system consisting of 10 elements, where each element can exist in one of four states (or classes). This means the system has 410410 possible states. For each element, I have 61 features that can be used to predict its state. I’ve experimented with different neural networks (FF networks have worked well so far), mainly focusing on predicting the labels of individual elements.
However, I’ve encountered some challenges:
The classes are naturally imbalanced.
The problem is non-deterministic, meaning two identical feature vectors can correspond to different labels.
I’ve been addressing these issues with relative success by applying techniques such as downsampling, oversampling, data augmentation, and soft labels (the latter has been the most effective).
Now, I want to predict the probability of the entire system being in each of its 410410 states. One issue I’ve noticed is that a misclassification error of 0.05 has minimal impact when the classification is close to random (e.g., 0.25), but it has a significant impact when probabilities are closer to 1 or 0.
What I’d like to do next is implement a loss function that considers the entire system rather than individual elements, while still being based on predictions for each element. My idea is to:
Take batches of 10 observations (corresponding to the 10 elements of the system).
Compute the probability of each element belonging to each of the 4 classes.
Calculate the probability of the system being in each of its 410410 possible states based on these predictions.
Sort these probabilities and use the known labels to find the index of the correct state.
Minimize this index.
Does this approach make sense? Is it feasible? And if so, how could it be implemented?
Many thanks!
DavidHi everyone,
First, thank you! This is a fantastic community from which I’m learning so much. This is my first question (hopefully, I’ll be able to contribute answers in the future!).
I have a system consisting of 10 elements, where each element can exist in one of four states (or classes). This means the system has 410410 possible states. For each element, I have 61 features that can be used to predict its state. I’ve experimented with different neural networks (FF networks have worked well so far), mainly focusing on predicting the labels of individual elements.
However, I’ve encountered some challenges:
The classes are naturally imbalanced.
The problem is non-deterministic, meaning two identical feature vectors can correspond to different labels.
I’ve been addressing these issues with relative success by applying techniques such as downsampling, oversampling, data augmentation, and soft labels (the latter has been the most effective).
Now, I want to predict the probability of the entire system being in each of its 410410 states. One issue I’ve noticed is that a misclassification error of 0.05 has minimal impact when the classification is close to random (e.g., 0.25), but it has a significant impact when probabilities are closer to 1 or 0.
What I’d like to do next is implement a loss function that considers the entire system rather than individual elements, while still being based on predictions for each element. My idea is to:
Take batches of 10 observations (corresponding to the 10 elements of the system).
Compute the probability of each element belonging to each of the 4 classes.
Calculate the probability of the system being in each of its 410410 possible states based on these predictions.
Sort these probabilities and use the known labels to find the index of the correct state.
Minimize this index.
Does this approach make sense? Is it feasible? And if so, how could it be implemented?
Many thanks!
David Hi everyone,
First, thank you! This is a fantastic community from which I’m learning so much. This is my first question (hopefully, I’ll be able to contribute answers in the future!).
I have a system consisting of 10 elements, where each element can exist in one of four states (or classes). This means the system has 410410 possible states. For each element, I have 61 features that can be used to predict its state. I’ve experimented with different neural networks (FF networks have worked well so far), mainly focusing on predicting the labels of individual elements.
However, I’ve encountered some challenges:
The classes are naturally imbalanced.
The problem is non-deterministic, meaning two identical feature vectors can correspond to different labels.
I’ve been addressing these issues with relative success by applying techniques such as downsampling, oversampling, data augmentation, and soft labels (the latter has been the most effective).
Now, I want to predict the probability of the entire system being in each of its 410410 states. One issue I’ve noticed is that a misclassification error of 0.05 has minimal impact when the classification is close to random (e.g., 0.25), but it has a significant impact when probabilities are closer to 1 or 0.
What I’d like to do next is implement a loss function that considers the entire system rather than individual elements, while still being based on predictions for each element. My idea is to:
Take batches of 10 observations (corresponding to the 10 elements of the system).
Compute the probability of each element belonging to each of the 4 classes.
Calculate the probability of the system being in each of its 410410 possible states based on these predictions.
Sort these probabilities and use the known labels to find the index of the correct state.
Minimize this index.
Does this approach make sense? Is it feasible? And if so, how could it be implemented?
Many thanks!
David neural network, classification, loss function, fast forward, trainnet MATLAB Answers — New Questions
What is the best practice for creating a recursion loop?
Hello all! I am trying to create a simple program that creates a fractal. It is supposed to be putting complex values into an array from the initial conditions and I will plot them later.
My Questions are:
1. What is the correct way to implement an Anonymous Function?
2. What is the best practice in Matlab for a recursion loop?
The answer to question 1 may not be necessary if the answer to 2 does not use Anonymous Functions.
clear all
clc
F = @(z) z^2 + c;
Re = [];
Im = [];
x = 1;
y = 1;
a = 2;
b = 3;
n = 10;
c = x+y*1i;
z0 = a+b*1i;
% Placing values in arrays to be plotted
Re(1,1) = real(z0 + c);
Im(1,1) = imag(z0 + c);
F(z0) = z; % First step of the recursion outside for loop?
% Second values for the array
Re(2,1) = real(z);
Im(2,1) = imag(z);
for h = (3:n) % Begin recursion
F(z) = z;
Re(h,1) = real(z);
Im(h,1) = imag(z);
h = h + 1;
endHello all! I am trying to create a simple program that creates a fractal. It is supposed to be putting complex values into an array from the initial conditions and I will plot them later.
My Questions are:
1. What is the correct way to implement an Anonymous Function?
2. What is the best practice in Matlab for a recursion loop?
The answer to question 1 may not be necessary if the answer to 2 does not use Anonymous Functions.
clear all
clc
F = @(z) z^2 + c;
Re = [];
Im = [];
x = 1;
y = 1;
a = 2;
b = 3;
n = 10;
c = x+y*1i;
z0 = a+b*1i;
% Placing values in arrays to be plotted
Re(1,1) = real(z0 + c);
Im(1,1) = imag(z0 + c);
F(z0) = z; % First step of the recursion outside for loop?
% Second values for the array
Re(2,1) = real(z);
Im(2,1) = imag(z);
for h = (3:n) % Begin recursion
F(z) = z;
Re(h,1) = real(z);
Im(h,1) = imag(z);
h = h + 1;
end Hello all! I am trying to create a simple program that creates a fractal. It is supposed to be putting complex values into an array from the initial conditions and I will plot them later.
My Questions are:
1. What is the correct way to implement an Anonymous Function?
2. What is the best practice in Matlab for a recursion loop?
The answer to question 1 may not be necessary if the answer to 2 does not use Anonymous Functions.
clear all
clc
F = @(z) z^2 + c;
Re = [];
Im = [];
x = 1;
y = 1;
a = 2;
b = 3;
n = 10;
c = x+y*1i;
z0 = a+b*1i;
% Placing values in arrays to be plotted
Re(1,1) = real(z0 + c);
Im(1,1) = imag(z0 + c);
F(z0) = z; % First step of the recursion outside for loop?
% Second values for the array
Re(2,1) = real(z);
Im(2,1) = imag(z);
for h = (3:n) % Begin recursion
F(z) = z;
Re(h,1) = real(z);
Im(h,1) = imag(z);
h = h + 1;
end anonymous function, recursion, fractal MATLAB Answers — New Questions