Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

# error when reading from xls sheet

1 visualizzazione (ultimi 30 giorni)
Ayda il 31 Ott 2011
Chiuso: MATLAB Answer Bot il 20 Ago 2021
Good evening\morning
I have a system of equations and i expressed them in matrix form
R=[ R(3)+R(5)+R(8) , -R(5) , 0 , -R(3);
-R(5), R(1)+R(4)+R(5)+R(7) , -R(4), 0;
0, -R(4) , R(2)+R(4)+R(6) , -R(6);
-R(3) , 0 , -R(6) , R(3)+R(6)+R(9)];
V= [V(1);0;0;V(2)];
I've to do a matrix division and some other things But when I read the voltages values from xls file as
10
0
0
10
it read it Matrix V (in Volts)
10.0
0.0
0.0
0.0
Also when it try to enter the value from the terminal it read it as zero
fid= fopen('mesh.txt','w');
% R=input('inter resistor value in kilo ohms, [R1...R9]= ');
% V=input('inter voltage value in volt, [V1 V2]= ');
R=[ R(3)+R(5)+R(8) , -R(5) , 0 , -R(3);
-R(5), R(1)+R(4)+R(5)+R(7) , -R(4), 0;
0, -R(4) , R(2)+R(4)+R(6) , -R(6);
-R(3) , 0 , -R(6) , R(3)+R(6)+R(9)];
V= [V(1);0;0;V(2)];
fprintf(fid,'Matrix R (in Kohms)\n\n');
fprintf(fid,'\t%.1f\t\t %.1f\t\t %.1f\t\t %.1f\t\n\n',R);
fprintf(fid,'Matrix V (in Volts)\n\n');
fprintf(fid,'%.1f\n %.1f\n %.1f\n %.1f\n\n',V);
I=R\V;
fprintf(fid,'Mesh Currents I (in mAmber)\n\n');
fprintf(fid,'%.4f\n %.4f\n %.4f\n %.4f\n\n',I);
inverse= inv(R);
fprintf(fid,'Inverse of R (in Kohms)\n\n');
fprintf(fid,'%.4f\t %.4f\t %.4f\t %.4f\t\n\n',inverse);
I=invers\V;
fprintf(fid,'Mesh Currents I (in mAmber)\n\n');
fprintf(fid,'%.4f\n %.4f\n %.4f\n %.4f\n',I);
fclose(fid);
##### 1 CommentoMostra NessunoNascondi Nessuno
bym il 31 Ott 2011
I think you have a number of typographical errors (typos) in your code; plus formatting it using the {}Code button would help readability and increase the probability someone would provide the answer you seek

### Risposte (1)

Ken Atwell il 2 Nov 2011
If the file 'v' contains '10;0;0;10', the statement:
V= [V(1);0;0;V(2)];
two lines later would reset V to '10;0;0;0' as you are observing. Do you mean:
V = [V(1); V(4)];

### Community Treasure Hunt

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

Start Hunting!