Help with my for loop please?
Afficher commentaires plus anciens
Hi,
I wrote some code below but it's not exactly how I want it; it's more like a demonstration of my ideal outcome. I'm trying to symbolically assign subscripts as the for loop goes on...so every time there's a u_i-1 or u_i-2..it's ideally meant to be u_(i-1) and u_(i-2).
My problem though is that I don't have a way of assigning symbolic subscripts within the for loop and as of right now the only way I can fix this is by manually editing each index of my matrix: Vector
Any help greatly appreciated :) :)
(PS I know a few variables are unassigned in my syms string, I have use for them later ^_^)
clear all
clc
syms P A_0 U L E j u x u_i
N = 4;
h = L/N;
k=N+2;
for i=1:k
vec = [u_i-2:u_i-1]+i;
mat(i,:) = vec;
Vector = fliplr(mat);
end
Vector
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Code Performance dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!