Effacer les filtres
Effacer les filtres

Creating linear equations in matlab

3 vues (au cours des 30 derniers jours)
Aftab Ahmed Khan
Aftab Ahmed Khan le 20 Fév 2016
Commenté : Star Strider le 22 Fév 2016
Hello,
How can i create 9 different equations in matlab if i have this general form of equations. I never did any thing of this kind before. I can enter these equations manually but i have very high number of equations (1000) so thats why i am looking for some method which can create it for me. In this case "n" is equal 2. Thank you so much

Réponse acceptée

Star Strider
Star Strider le 20 Fév 2016
This is how I would build your matrix:
C = pi; % Assume A Value For ‘C’, A Scalar
n = 3; % Choose ‘n’
P = randi(99, n); % Create ‘P’
for j1 = 2:(n-1)
for j2 = 2:(n-1)
M(j1, j2) = C*P(j1, j2) - C * P(j1+1, j2) - C * P(j1, j2+1) - C * P(j1, j2-1);
end
end
j1 = n-1;
for j2 = 2:(n-1)
M(j1, j2) = C*P(j1, j2) - C * P(j1+1, j2) - C * P(j1, j2+1) - C * P(j1, j2-1) - C * P(j1, j2-1);
end
j1 = n;
j2 = n;
M(j1, j2) = C * P(j1, j2) - C * P(j1-1, j2) - C * P(j1, j2-1);
Note that MATLAB indices begin with 1 (all index references have to be positive integers), so it’s necessary to consider that in the code and make the appropriate changes. If you want to use this in a solver function of some sort, I would wrap the loops in a function and then use that function as the objective function of the solver. There may be more efficient ways to create your matrix, but I decided to just go with the description you provided.
You will likely have to experiment with this to get the result you want, but this should get you started.
While I’m thinking about it, let us know how your communications research goes, and attach PDFs of papers you publish from it, especially those that include MATLAB scripts or functions. Also, if you develop any MATLAB scripts that could be useful for others, document them thoroughly and submit them to the File Exchange.
  4 commentaires
Aftab Ahmed Khan
Aftab Ahmed Khan le 22 Fév 2016
Ok thank you. Here is my first paper. I will also send you my second paper which is under review. I really appreciate your help.
Star Strider
Star Strider le 22 Fév 2016
As always, my pleasure.
Thank you. I saved it and will look at it later. It’s far from my areas of expertise, so I’ll definitely learn from it.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Parallel Computing dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by