need help to find all results in one table , or any possible form
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hello, every one
I need to calculate the equation
y=sum((x - 4).^2) / 2; for every R1 less than R2
( where x contain a, b which contains many numbers)
and , Is it possible in matlab to get the results in one table that contains all results (or something similar to the table, or any form) so that it is easy to see all the results from all loops as
R2 R1 y
(or p3 p1 y, as my code),??? therefore % I try to repeat p2 to get the suitable table , for the need for every R1 less than R2, I thought I must repeat R2 to the length(R1)
the error of my result in my code is
Unrecognized function or variable 'p3'.
Error in average (line 22)
T=table(p3,p1,y)
if any prof can help me to correct my code, thanks alot
0 Commenti
Risposta accettata
Kevin Holly
il 29 Set 2021
Is this what you were trying to do?
R1=1:1:10;
R2=1:1:10;
a=[22 17 20 7 33 19 8 30 4 9 36 14 12 44 40 ]';
b=[25 18 44 26 35 33 9 44 8 22 40 15 22 50 50]';
T =[];
for j=1:length(R2)
y=0;
for i=1:length(R1)
if R1(i)<R2(j)
x=((1/2)*((b-a)*R1(i)-(b-a)*R2(j)+(b+a)));
y=y+sum((x - 5).^2) / 2;
T = [T; [R1(i) R2(j) y]];
end
end
end
array2table(T,'VariableNames',{'R1','R2','y'})
%or table(T(:,1),T(:,2),T(:,3),'VariableNames',{'R1','R2','y'})
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Tables in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!